EclipseでTomcatをMavenで使用する最良の方法を探しています。EclipseでmavenとTomcatを正しく使用する方法
Java EEアプリケーションの開発経験はありますが、Mavenを使用する場合も同様の動作が期待されます。
私の要件は単純です:
- 簡単なアプリケーションの構築
- 簡単な展開
- 可能な場合は、ホットスワップ
私は知らないどのように詳細にTomcatの+ Eclipseの仕事私はそうMavenコマンドと仮定します。
mvn eclipse:eclipse -Dwtpversion=2.0
はすべて正しく設定されていますが、うまく動作していない(または少なくとも予想通り)という疑いがあります。
プロジェクト(テストと呼ぶ)がmavenに組み込まれている場合、結果は${project}/target/test
というフォルダにあります。しかし、Tomcatのクラスは別のフォルダ(${project}/target/classes
?)から来ているようです。これは間違っています(私が間違っていれば私を修正します)。しかし、Mavenはコード生成、リソースフィルタリング、AOP製織などのクラスを構築する前に他のアクションを実行できます。
使用方法はいくつかありますか?コマンドラインからmvn clean install
を実行し、その結果をTomcatにデプロイすることは、IDE(統合開発環境)として私には聞こえません。それを正しく設定するには、maven eclipseプラグインに指示することは可能ですか?
私はまた、mvn tomcat:run
を使用しようとしましたが、ここで私は完全に失われています、私はエラーを理解していません。
java.lang.NoSuchMethodError: org.apache.cxf.common.classloader.ClassLoaderUtils.loadClass
と私は、Tomcatのための日食から罰金6つの作品をサーバーランタイムを使用している間、それは働いていない理由はわかりません。
私はクラスを保存すると、mvn install
と言うようにEclipseに指示することはできますか?それは働くだろうか?それは標準のJSEプロジェクトに慣れていたように、変更されたものだけを再構築することと依存関係を再構築するのに十分速いでしょうか?実際
私が使用している
- のMaven 3.0.4
- javaの1.6
- 日食4.2.1(STS 3.2.0.M2)
- のTomcat 6(私たちは現在のために開発されていますTomcatの6、私はそれが7に同じだと思う)
編集
のpom.xml
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
<!-- WSDL -> Java (start) -->
<cxf.version>2.7.3</cxf.version>
<cxf-codegen-plugin.version>2.6.1</cxf-codegen-plugin.version>
<cxf.sourceRoot>src/main/generated</cxf.sourceRoot>
<!-- WSDL -> Java (end) -->
<junit.version>4.11</junit.version>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<project.build.date>${maven.build.timestamp}</project.build.date>
</properties>
<dependencies>
...
</dependencies>
<build>
<resources>
<resource>
<!-- filtering used to replace variables from in property files -->
<filtering>true</filtering>
<directory>${basedir}/src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- add src/main/generated for maven -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- WSDL -> Java (start) -->
<plugin>
<!-- !!! READ !!! -->
<!-- mvn cxf-codegen-plugin:wsdl2java NOT working, comment phase and run "mvn clean install -DskipTests") -->
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-codegen-plugin.version}</version>
<executions>
...
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.5.1</version>
<inherited>true</inherited>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1.1</version>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>test</warName>
</configuration>
</plugin>
<!-- resources in UTF-8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- JUnit -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>1.5</wtpversion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
ポームを投稿してください。パッケージングは戦争に設定されていますか? – guerda
サーバービューが必要です。右クリックしてサーバーを追加してTomcatを選択すると、Eclipse内からWebプロジェクトを展開できます。それもホットスワップをサポートしています。 –
@furtelwart:私の実際のpom.xmlはここに投稿するのが大変です(この質問にはたくさんのものは関係ありません)。あなたのコメントには、私は ' war 'があり、私のポームには '私の問題はそれが機能していないのではなく、複雑すぎる... @Bob Flannigon:これは間違ったフォルダ($ {project}/target/classes)をとります私の質問に書いたように... –
Betlista