2012-03-14 105 views
0

我創建了一個示例cxf服務,其中包含以下工件。在eclipse中導入項目。選擇Run As> Maven的安裝Maven在第一次運行後不部署應用程序/啓動服務器

它沒有執行編譯>戰爭>的startserver>部署戰爭>執行測試>停止服務器

現在做的代碼和測試類的一些變化,當我做MVN安裝後,它不啓動/停止服務器,也不在tomcat上部署。 POM如下。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.domain.test.jaxrs</groupId> 
    <artifactId>jaxrs-test</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <name>Simple CXF JAX-RS webapp service using spring configuration</name> 
    <description>Simple CXF JAX-RS webapp service using spring configuration</description> 
    <properties> 
     <jackson.version>1.8.6</jackson.version> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>org.apache.cxf</groupId> 
      <artifactId>cxf-rt-frontend-jaxrs</artifactId> 
      <version>2.5.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-core-asl</artifactId> 
      <version>${jackson.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>${jackson.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-jaxrs</artifactId> 
      <version>${jackson.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 
    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>tomcat-maven-plugin</artifactId> 
        <version>1.1</version> 
        <executions> 
         <execution> 
          <id>default-cli</id> 
          <goals> 
           <goal>run</goal> 
          </goals> 
          <configuration> 
           <port>13000</port> 
           <path>/jaxrs-service</path> 
           <useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <configuration> 
         <source>1.5</source> 
         <target>1.5</target> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-eclipse-plugin</artifactId> 
        <configuration> 
         <projectNameTemplate>[artifactId]-[version]</projectNameTemplate> 
         <wtpmanifest>true</wtpmanifest> 
         <wtpapplicationxml>true</wtpapplicationxml> 
         <wtpversion>2.0</wtpversion> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.5</version> 
       <executions> 
        <execution> 
         <id>reserve-network-port</id> 
         <goals> 
          <goal>reserve-network-port</goal> 
         </goals> 
         <phase>process-test-resources</phase> 
         <configuration> 
          <portNames> 
           <portName>test.server.port</portName> 
          </portNames> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat-maven-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>start-tomcat</id> 
         <goals> 
          <goal>run-war</goal> 
         </goals> 
         <phase>pre-integration-test</phase> 
         <configuration> 
          <port>${test.server.port}</port> 
          <path>/jaxrs-service</path> 
          <fork>true</fork> 
          <useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader> 
         </configuration> 
        </execution> 
        <execution> 
         <id>stop-tomcat</id> 
         <goals> 
          <goal>shutdown</goal> 
         </goals> 
         <phase>post-integration-test</phase> 
         <configuration> 
          <path>/jaxrs-service</path> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.8.1</version> 
       <executions> 
        <execution> 
         <id>integration-test</id> 
         <goals> 
          <goal>integration-test</goal> 
         </goals> 
         <configuration> 
          <systemPropertyVariables> 
           <service.url>http://localhost:${test.server.port}/jaxrs-service</service.url> 
          </systemPropertyVariables> 
         </configuration> 
        </execution> 
        <execution> 
         <id>verify</id> 
         <goals> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

回答

0

明白了......「Convention over Configuration ....」是個問題....測試應運行在集成測試階段。對於這個應該命名測試* IT.java :)

這解決了問題。

相關問題