Spring3+Maven+Tomcat6 Web プロジェクトで..
REST APIコントローラーで同じRequestMappingを使用しようとしています。
なぜなら.. 使用方法が異なる別の戦争が必要だからです。
そのため、同じ名前のコントローラーを生成しましたが、パッケージは異なります。
例:
1. xxx.controller.agent.UserController
2. xxx.controller.console.UserController
1. maven -> build(war:war) -> get console.war include xxx.controller.agent.UserController
2. testExcludes と excludesのコメント行のコメントを外し
ます 3. testExcludes のコメント行をコメント解除しますおよび除外
4. maven -> プロジェクト構成の更新
5. maven -> ビルド (war:war) -> エージェント war の取得 xxx.controller.console.UserController を含める
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<exclude>com/test/store/controller/agent/*.java</exclude>
<exclude>com/test/rbac/controller/agent/*.java</exclude>
<!-- <exclude>com/test/store/controller/console/*.java</exclude>
<exclude>com/test/rbac/controller/console/*.java</exclude> -->
</testExcludes>
<excludes>
<exclude>com/test/store/controller/agent/*Controller.java</exclude>
<exclude>com/test/rbac/controller/agent/*Controller.java</exclude>
<!-- <exclude>com/test/store/controller/console/*Controller.java</exclude>
<exclude>com/test/rbac/controller/console/*Controller.java</exclude> -->
</excludes>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
しかし、各 war ビルドの pom.xml を編集したくありません。Mavenプロファイル要素を使用して各warファイルを構築しようとしています。そのため、以下に示すように pom.xml を編集しました。
<properties>
<exclude.console.store>com/test/store/controller/agent/**</exclude.console.store>
<exclude.console.rbac>com/test/rbac/controller/agent/**</exclude.console.rbac>
<exclude.agent.store>com/test/store/controller/console/**</exclude.agent.store>
<exclude.agent.rbac>com/test/rbac/controller/console/**</exclude.agent.rbac>
</properties>
...
<profiles>
<profile>
<id>console</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<packagingExcludes>
WEB-INF/classes/${exclude.console.store},
WEB-INF/classes/${exclude.console.rbac}
</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<exclude>${exclude.console.store}</exclude>
<exclude>${exclude.console.rbac}</exclude>
</testExcludes>
<excludes>
<exclude>${exclude.console.store}</exclude>
<exclude>${exclude.console.rbac}</exclude>
</excludes>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>agent</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<packagingExcludes>
WEB-INF/classes/${exclude.agent.store},
WEB-INF/classes/${exclude.agent.rbac},
WEB-INF/classes/spring/task.xml
</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<exclude>${exclude.agent.store}</exclude>
<exclude>${exclude.agent.rbac}</exclude>
</testExcludes>
<excludes>
<exclude>${exclude.agent.store}</exclude>
<exclude>${exclude.agent.rbac}</exclude>
</excludes>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
そして Maven ビルド.. (goal="package" または "compile war:war", profile="console" または "agent" それぞれの場合)
ビルドは成功しました..(コンパイル エラーなし) しかし、war は異常です。
war ファイルを tomcat webapp ディレクトリにコピーし、startup.bat ファイルを実行します。
コンソール ログでは、非常に多くのエラーが発生しました。
たぶん、maven compile に問題があると思います.war
ファイルを各ビルド方法 (プロファイルと古い方法を使用) で展開しました。
しかし、クラスファイルの数が異なっていました...
ご協力ありがとうございます。