Launch tomcat from Maven with context.xml and injected password
I'm trying to set up a Maven pom.xml file such that it will
I need the username and password to be external from the project so that the sensitive info isn't stored in version control.
The Maven tomcat plugin is working fine if I hard code the username and password. I put the context.xml fil in src/test/resources/tomcat/context.xml and configured the plugin to pull it from there:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<contextFile>
${project.basedir}/src/test/resources/tomcat/context.xml
</contextFile>
</configuration>
</plugin>
I've seen examples of putting the username and password in the .m2/settings.xml file as follows:
<servers>
<server>
<id>demo</id>
<username>myUser</username>
<password>myPassword</password>
</server>
<servers>
But I don't know how to "inject" those values into the context.xml. I've putting the following in the appropriate points in my context.xml:
${servers.server.demo.username}
or
${servers.server.username}
but they're not resolving to the actual value.
What's the best practice for this kind of thing?
You need to add 'server' tag inside 'configuration' and specify its id as value. In your case this is a 'demo'.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<contextFile>
${project.basedir}/src/test/resources/tomcat/context.xml
</contextFile>
<server>demo</server>
</configuration>
</plugin>
链接地址: http://www.djcxy.com/p/62958.html
上一篇: 忽略元素