Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tomcat7 maven插件custom server.xml_Tomcat_Maven_Maven 3 - Fatal编程技术网

tomcat7 maven插件custom server.xml

tomcat7 maven插件custom server.xml,tomcat,maven,maven-3,Tomcat,Maven,Maven 3,我正在尝试使用tomcat7 maven插件:与自定义server.xml一起运行,其中包含我需要启用的领域。如文档中所述,我使用指向我的文件。但是,我的应用程序不会加载。插件文档声明我需要手动配置应用程序的上下文 我该怎么做?我不确定该为docBase等放置什么 谢谢。您是否可以检查此示例pom如果您只需要更改域,那么就不要使用server.xml而使用context.xml: <Context> <Realm className="org.apache.catalina

我正在尝试使用tomcat7 maven插件:与自定义server.xml一起运行,其中包含我需要启用的领域。如文档中所述,我使用
指向我的文件。但是,我的应用程序不会加载。插件文档声明我需要手动配置应用程序的上下文

我该怎么做?我不确定该为docBase等放置什么


谢谢。

您是否可以检查此示例pom

如果您只需要更改域,那么就不要使用
server.xml
而使用
context.xml

<Context>
  <Realm className="org.apache.catalina.realm.MemoryRealm" />
</Context>

我已经使用下载的tomcat发行版中的参考配置了custom server.xml,并更新了端口号和其他端口号,当我遇到以下问题时,答案如下。 注意:它只在版本为2.1的tomcat7 maven插件工件中工作,而不是在版本为2.2的tomcat7 maven插件工件中工作

查找我的pom.xml和server.xml

  <project>
  ...
  <packaging>war or pom</packaging>
  ...
  <build>
    ...
    <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warName>secured-sample-webapp</warName>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>**/*.tag</include>
                                <include>**/*.jsp</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>false</filtering>
                            <excludes>
                                <exclude>**/*.tag</exclude>
                                <exclude>**/*.jsp</exclude>
                            </excludes>
                        </resource>
                    </webResources>
                    <packagingExcludes>less/**</packagingExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <executions>
                      <execution>
                        <id>tomcat-run</id> 
                        <goals>
                          <goal>exec-war-only</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                          <path>/secured-sample-webapp</path>
                          <warDirectory>target/secured-sample-webapp</warDirectory>
                          <!-- optional, needed only if you want to use a preconfigured server.xml file -->
                          <serverXml>src/main/tomcatconf/server.xml</serverXml>
                          <!-- optional values which can be configurable -->
                          <attachArtifactClassifier>exec-war</attachArtifactClassifier>
                          <attachArtifactClassifierType>jar</attachArtifactClassifierType>
                          <finalName>secured-sample-webapp-exec.jar</finalName>
                          <enableNaming>true</enableNaming>
                        </configuration>
                      </execution>
                    </executions>
               </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

...
战争还是pom
...
...
org.apache.maven.plugins
maven编译器插件
${java版本}
${java版本}
org.apache.maven.plugins
maven战争插件
安全示例webapp
src/main/webapp
真的
**/*.标签
**/*.jsp
src/main/webapp
假的
**/*.标签
**/*.jsp
少/**
org.apache.maven.plugins
maven依赖插件
安装
安装
来源
org.apache.tomcat.maven
tomcat7 maven插件
2.1
雄猫赛跑
仅限执行战争
包裹
/安全示例webapp
目标/安全示例webapp
src/main/tomcatconf/server.xml
执行战争
罐子
secured-sample-webapp-exec.jar
真的
...
...
...
及 Server.xml

 <Server port="8005" shutdown="SHUTDOWN">
  <!--  <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> -->
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  ...
  <Service>
  ...
  <Engine>
  ...
  <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

             <Context docBase="../../secured-sample-webapp" path="/secured-sample-webapp" reloadable="true" />

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>

    </Engine>
  </Service>
</Server>

...
...
...

如果能看到您的
server.xml
too您能发布server.xml吗?我也有同样的问题,但不能让它工作。获取以下错误:“文档库…不存在或不是可读目录”。我使用的是“tomcat7:run”,不知道需要什么路径。谢谢
 <Server port="8005" shutdown="SHUTDOWN">
  <!--  <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> -->
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  ...
  <Service>
  ...
  <Engine>
  ...
  <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

             <Context docBase="../../secured-sample-webapp" path="/secured-sample-webapp" reloadable="true" />

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>

    </Engine>
  </Service>
</Server>