0

私はMavenを使用してプロジェクトを管理しています。

<properties>タグは非常に便利ですが、これには問題があります。

ソースをTomcatにデプロイするときは、/target/classesDeploymentAssemblyに入れて変換されたリソースを取得する必要があります。

例) ここに画像の説明を入力してください 上記は正しいと思います。


ここに画像の説明を入力してください しかし、私は/target/classes/変換されたプロパティを取得するために置く必要があります。

春豆の例)

<!-- Database -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${database.classname}" />
        <property name="defaultAutoCommit" value="${database.defaultAutoCommit}" />
        <property name="testWhileIdle" value="${database.testWhileIdle}" />
        <property name="timeBetweenEvictionRunsMillis" value="${database.timeBetweenEvictionRunsMillis}" />
        <property name="url" value="${database1.url}" />
        <property name="username" value="${database1.username}" />
        <property name="password" value="${database1.password}" />
    </bean>

この純粋な変数は、私が入れなければ、TomcatのWebアプリケーションにコピーされただけです/target/classes/

それは機能しますが、Eclipseが時々言うので、これは私を夢中にさせます"sources are not sychronized!"


pom.xml

...
    <build>
        <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
        <outputDirectory>${basedir}/target/webapp/WEB-INF/classes</outputDirectory>

        <resources>
            <resource>
                <directory>${basedir}/src/main/webapp</directory>
                <targetPath>${basedir}/target/webapp</targetPath>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <targetPath>${basedir}/target/webapp/WEB-INF/classes</targetPath>
                <filtering>true</filtering>
            </resource>
        </resources>

        <filters>
            <filter>${basedir}/src/main/resources/spring-common-bean-context.xml</filter>
            <filter>${basedir}/src/main/resources/byto.cyoz.properties</filter>
        </filters>
...
4

0 に答える 0