简体   繁体   English

Maven WebApp META-INF context.xml

[英]Maven WebApp META-INF context.xml

I am using Maven 3 and I am trying to add META-INF folder under webapp folder. 我正在使用Maven 3,我正在尝试在webapp文件夹下添加META-INF文件夹。 So I am trying to do the following: 所以我想尝试以下方法:

src
 main
  webapp
   META-INF
    context.xml
   WEB-INF

Below is my POM file: 以下是我的POM文件:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.data</groupId>
<artifactId>Java-WebApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Java-Web Application</name>

<!-- Shared version number properties-->
<properties>
<org.springframework.version>3.0.6.RELEASE</org.springframework.version>
</properties>

<dependencies>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
  </dependency>
 </dependencies>
<build>
<finalName>data</finalName>
</build>

<parent>
<groupId>com.data</groupId>
<artifactId>Java-Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>

Under src/main/resources I have added a META-INF\\context.xml. 在src / main / resources下我添加了一个META-INF \\ context.xml。 When the WAR file is packaged using mvn package the structure looks like this: 当使用mvn包打包WAR文件时,结构如下所示:

data
 webapp
  META-INF
  WEB-INF
  index.jsp

The relevant files under WEB-INF can be seen. 可以看到WEB-INF下的相关文件。 However, the META-INF folder is blank. 但是,META-INF文件夹是空白的。 My default Maven will add resources under the WEB-INF/classes. 我的默认Maven将在WEB-INF / classes下添加资源。

I want specifically would like to have: 我想特别希望:

data
 webapp
  META-INF
   context.xml
  WEB-INF

How is this possible? 这怎么可能? I have tried other things, but still it does not work. 我尝试了其他的东西,但它仍然没有用。 The context.xml contains the following: context.xml包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/data1"/>

I have tried removing the META-INF folder from src\\main\\resources and directly put it under webapp\\META-INF. 我尝试从src \\ main \\ resources中删除META-INF文件夹,并直接将其放在webapp \\ META-INF下。 The context.xml displays but when deployed into Tomcat, the context root that I have defined does not work. context.xml显示但是当部署到Tomcat时,我定义的上下文根不起作用。

Put your META-INF folder within src/main/resources. 将META-INF文件夹放在src / main / resources中。

Put this on your pom.xml... sorry i missed it before; 把它放在你的pom.xml上......对不起我以前错过了它;

<build>
<plugins>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>


                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                </archive>

                <webResources>
                    <resource>
                        <!-- this is relative to the pom.xml directory -->
                        <directory>${project.basedir}/src/main/resources
                        </directory>

                    </resource>
                </webResources>



                <warName>mywar</warName>
            </configuration>
        </plugin>
</plugins>
</build>

the web resources tag is what is important... Hope this helps 网络资源标签是重要的......希望这会有所帮助

Use the tag instead. 请改用标签。 Above answer using copies everything in src/main/resources to the root of your web application, which is probably not what you want to do nor an example you want to follow. 上面的答案使用将src / main / resources中的所有内容复制到Web应用程序的根目录,这可能不是您想要做的,也不是您想要遵循的示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 META-INF / context.xml导致我的Java Webapp出现问题 - META-INF/context.xml causing problems in my Java Webapp 如何在Maven的包生成期间选择一个/META-INF/context.xml? - How can I chose one /META-INF/context.xml during the Maven's package generation? Maven-war-plugin覆盖删除/META-INF/context.xml - maven-war-plugin overlay removes /META-INF/context.xml 无法将META-INF / context.xml重新加载到../conf/Catalina/localhost/myapp.xml - reloading META-INF/context.xml to ../conf/Catalina/localhost/myapp.xml not working Tomcat中context.xml的正确META-INF目录位置是什么? - What is the correct META-INF directory location for context.xml in Tomcat? 可以从某些属性文件中读取Tomcat中的Web / Meta-Inf / Context.xml - can Web/Meta-Inf/Context.xml read in Tomcat from some properties file 部署战争。 Tomcat 不考虑上下文。考虑到 META-INF 中的 xml - Deploying War. Tomcat not taking context.xml from META-INF in consideration 无法使用META-INF / context.xml文件连接Servlet JDBC连接池中的数据库 - unable to connect database in Servlet JDBC Connection Pool using META-INF/context.xml file 如何在开发和生产环境中使用不同的META-INF / context.xml文件 - How to Use Different META-INF/context.xml Files For Development and Production Environments 如何在java war文件中的META-INF / context.xml内的Tomcat 8上指定“上下文路径”? - How can I specify “Context path” on Tomcat 8 inside META-INF/context.xml in java war file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM