我有一个maven项目,它与tomcat 7插件合并。每当我做maven:在war文件中安装它的生成并将它放在tomcat web apps文件夹中,我可以使用localhost访问:8080
现在我想将tomcat7更改为tomcat 8并且还想分别运行tomcat。
现在我正在使用带有maven的Tomcat7插件,我不想使用Tomcat 7和maven,我想使用我系统中的Tomcat 8。
怎么做?
对于我的新tomcat服务器,可以告诉maven将生成的war文件放到新的tomcat服务器webapps文件夹中。
请找我的tomcat插件配置下面的pom.xml
<!-- Used by embedded Tomcat to move context.xml for JNDI resources -->
<!-- Configuration inherited from parent -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<!-- Main configuration inherited from parent -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>${httpPort}</port>
<httpsPort>${httpsPort}</httpsPort>
</configuration>
</plugin>
以下是我的ant脚本,它将有助于在嵌入式tomcat中部署war文件
<target name="tomcat" >
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<jvmarg value="-Ddatabase.user=${database.user}" />
<jvmarg value="-Ddatabase.password=${database.password}" />
<jvmarg value="-Ddatabase.driver=${database.driver}" />
<jvmarg value="-Ddatabase.url=${database.url}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="tomcat7:run"/>
</artifact:mvn>
</target>
我的父Pom.xml
<!-- Moves the context.xml file into a location that embedded Tomcat can read from -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${tomcat.conf.dir.name}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../lib/${tomcat.conf.dir.name}</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Main coniguration for embedded Tomcat -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- Useful when deploying to Tomcat elsewhere on the system -->
<update>true</update>
<url>http://127.0.0.1:8080/manager/text</url>
<username>tomcatscript</username>
<password>secret</password>
<additionalConfigFilesDir>${project.build.directory}/${tomcat.conf.dir.name}</additionalConfigFilesDir>
<!-- See the configuration in the keytool-maven-plugin -->
<keystorePass>broadleaf</keystorePass>
<keystoreFile>${webappDirectory}/WEB-INF/blc-example.keystore</keystoreFile>
<!-- System properties for JNDI data sources (database.url, database.driver etc) are passed in via -->
<!-- build.xml as -D arguments -->
</configuration>
<dependencies>
<!-- Other dependencies -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.30</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
现在如何更改我的pom.xml或ant脚本以删除嵌入式tomcat并包含本地tomcat 当我运行我的ant脚本时,Maven应该能够部署或重新部署到本地tomcat安装。
谢谢
答案 0 :(得分:0)
首先,您需要删除启动Tomcat7的tomcat7-maven-plugin相关配置。
其次,您可以配置tomcat7-maven-plugin以使用Tomcat X REST管理API并使用maven按照所述http://www.disasterarea.co.uk/blog/deploying-to-tomcat-7-with-maven/
部署您的战争