tomcat-maven-plugin忽略自定义web.xml和context.xml

时间:2016-05-04 13:29:42

标签: java maven tomcat maven-plugin maven-tomcat-plugin

我正在尝试使用自定义“finalName”测试一个Web项目,但是当我执行mvn tomcat7时:运行tomcat会忽略自定义文件web.xml和context.xml。

默认的context.xml文件既不是由嵌入式tomcat加载的。

这是pom.xml中的插件配置:

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <charset>UTF-8</charset>
                <mode>context</mode>
                <!-- naming is disabled by default so use true to enable it -->
                <enableNaming>true</enableNaming> <!-- tomcat6 -->
                <useNaming>true</useNaming> <!-- tomcat7 -->
                <contextFile>${project.basedir}/src/tomcat7-maven-plugin/resources/project.xml</contextFile>
                <tomcatWebXml>${project.basedir}/src/tomcat7-maven-plugin/resources/web.xml</tomcatWebXml>
                <contextReloadable>true</contextReloadable>
                <!--  <path>/${project.build.finalName}</path> -->
                <port>${tomcat.webport}</port>
                <ajpPort>${tomcat.ajpport}</ajpPort>
                <systemProperties>
                    <JAVA_OPTS>-XX:MaxPermSize=256m</JAVA_OPTS>
                </systemProperties>
                <extraDependencies> <!-- tomcat 7 -->
                    <dependency>
                        <groupId>com.microsoft.sqlserver</groupId>
                        <artifactId>sqljdbc42</artifactId>
                        <version>4.2.6420.100</version>
                        <scope>runtime</scope>
                    </dependency>
                </extraDependencies>
            </configuration>
            <dependencies> <!-- tomcat 6  -->
                <dependency>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>sqljdbc42</artifactId>
                    <version>4.2.6420.100</version>
                </dependency>
            </dependencies>
        </plugin>

这是插件调试输出:

[DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run' with basic configurator -->
[DEBUG]   (f) addContextWarDependencies = false
[DEBUG]   (f) addWarDependenciesInClassloader = true
[DEBUG]   (f) additionalConfigFilesDir = C:\Users\test\Documents\wp-eclipse-kepler\project\src\main\tomcatconf
[DEBUG]   (f) ajpPort = 0
[DEBUG]   (f) ajpProtocol = org.apache.coyote.ajp.AjpProtocol
[DEBUG]   (f) backgroundProcessorDelay = -1
[DEBUG]   (f) clientAuth = false
[DEBUG]   (f) configurationDir = C:\Users\test\Documents\wp-eclipse-kepler\project\target\tomcat
[DEBUG]   (f) contextFile = C:\Users\test\Documents\wp-eclipse-kepler\project\src\tomcat7-maven-plugin\resources\project.xml
[DEBUG]   (f) contextReloadable = true
[DEBUG]   (f) defaultContextFile = C:\Users\test\Documents\wp-eclipse-kepler\project\target\project\META-INF\context.xml
[DEBUG]   (f) delegate = true
[DEBUG]   (f) port = 8080
[DEBUG]   (f) protocol = HTTP/1.1
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@3a7c678b
[DEBUG]   (f) skip = false
[DEBUG]   (f) staticContextPath = /
[DEBUG]   (f) systemProperties = {JAVA_OPTS=-XX:MaxPermSize=256m}
[DEBUG]   (f) tomcatWebXml = C:\Users\test\Documents\wp-eclipse-kepler\project\src\tomcat7-maven-plugin\resources\web.xml
[DEBUG]   (f) uriEncoding = ISO-8859-1
[DEBUG]   (f) useBodyEncodingForURI = false
[DEBUG]   (f) useNaming = true
[DEBUG]   (f) useSeparateTomcatClassLoader = false
[DEBUG]   (f) useTestClasspath = false
[DEBUG]   (f) warSourceDirectory = C:\Users\test\Documents\wp-eclipse-kepler\project\src\main\webapp
[DEBUG]   (f) project = MavenProject: com.abb.csis.app:project:1.6.4-rc2 @ C:\Users\esalcor\Documents\wp-eclipse-kepler\project\pom.xml
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@18c04885

我阅读了文档,但我没有看到任何错误。

0 个答案:

没有答案