2012-03-14 79 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 :)

这解决了问题。

相关问题