Domanda

I want to shutdown the tomcat7 from maven by goal(Apache Tomcat Maven Plugin):

mvn tomcat7:shutdown

Could somebody provide an example of it? Now, I have only 'build success' after that goal complete, but server continue to work.

È stato utile?

Soluzione

This will be because you don't have an embedded Tomcat running.

An example would be to bind tomcat7:run to your pre-integration-test phase, this will start your Tomcat server embedded inside your Maven build, and then you might bind tomcat7:shutdown to the post-integration-test phase after you've run your tests.

If you want to launch Tomcat with a war that you've built in Maven then you can create your own run profile.

Something like the following will work:

<profiles>
         <profile>
             <id>run</id>
             <build>
                 <plugins>
                     <plugin>
                         <groupId>org.apache.tomcat.maven</groupId>
                         <artifactId>tomcat7-maven-plugin</artifactId>
                         <executions>
                             <execution>
                                 <id>run-wars</id>
                                 <goals>
                                     <goal>run-war-only</goal>
                                 </goals>
                                 <phase>integration-test</phase>
                             </execution>
                         </executions>
                         <configuration>
                            <warDirectory>theWar</warDirectory>
                            <path>/relativepath</path>
                            <systemProperties>
                            <webapps>
                                <webapp>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>myArtifact</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                    <asWebapp>true</asWebapp>
                                    <contextPath>myContext</contextPath>
                                 </webapp>
                             </webapps> 
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
</profiles>

You can run this with mvn package -Prun and then you can simply shut it down with Ctrl+C.

What Maven isn't going to do is to shutdown all running Tomcat instances on your machine, which is what looks like is implied by your trying to run that command on its own. In that case find your tomcat and run shutdown.sh.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top