Usage
If no explicit configuration is provided then the Tomcat Maven Plugin defaults to the following:
Tomcat manager URL of http://localhost:8080/manager
Authentication details of username admin and no password
Context path of /${project.artifactId}
These can be overridden as described below.
Using a different Tomcat manager URL
To configure the plugin for a different Tomcat instance, add a plugin configuration block to your pom.xml as follows:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>The default Tomcat manager URL is http://localhost:8080/manager.
Using different Tomcat manager authentication details
To specify a different username and password to use when authenticating with Tomcat manager:
Add a plugin configuration block to your pom.xml:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>myserver</server>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>Add a corresponding server block to your settings.xml:
<settings>
...
<servers>
...
<server>
<id>myserver</id>
<username>myusername</username>
<password>mypassword</password>
</server>
...
</servers>
...
</settings>The default authentication details are username admin and no password.
Using a different context path
The default context path is /${project.artifactId}.
To change the context path to /mycontext configure the plugin like this:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/mycontext</path>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>If you are using project.build.finalName to change the name of your WAR file, you can use that value when you configure the context path as well. To do that add the following configuration block to your pom.xml:
<project>
...
<build>
...
<finalName>mycontext</finalName>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>
If no explicit configuration is provided then the Tomcat Maven Plugin defaults to the following:
Tomcat manager URL of http://localhost:8080/manager
Authentication details of username admin and no password
Context path of /${project.artifactId}
These can be overridden as described below.
Using a different Tomcat manager URL
To configure the plugin for a different Tomcat instance, add a plugin configuration block to your pom.xml as follows:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>The default Tomcat manager URL is http://localhost:8080/manager.
Using different Tomcat manager authentication details
To specify a different username and password to use when authenticating with Tomcat manager:
Add a plugin configuration block to your pom.xml:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>myserver</server>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>Add a corresponding server block to your settings.xml:
<settings>
...
<servers>
...
<server>
<id>myserver</id>
<username>myusername</username>
<password>mypassword</password>
</server>
...
</servers>
...
</settings>The default authentication details are username admin and no password.
Using a different context path
The default context path is /${project.artifactId}.
To change the context path to /mycontext configure the plugin like this:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/mycontext</path>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>If you are using project.build.finalName to change the name of your WAR file, you can use that value when you configure the context path as well. To do that add the following configuration block to your pom.xml:
<project>
...
<build>
...
<finalName>mycontext</finalName>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>
本文详细介绍了如何使用TomcatMaven插件进行个性化部署配置,包括改变Tomcat管理URL、设置不同的认证详情、修改上下文路径等。
1057

被折叠的 条评论
为什么被折叠?



