Java Spring Boot + WEB-INF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27991474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring Boot + WEB-INF
提问by Mayurb
I have a very simple spring boot project with dependency
我有一个非常简单的带有依赖项的 spring boot 项目
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
When I build this , web-inf folder gets created in target directory, and packages everything in classes, and lib folder.
当我构建这个时,在目标目录中创建了 web-inf 文件夹,并将所有内容打包在类和 lib 文件夹中。
I want to have one xml file ("jboss-deployment-structure.xml") at the root of the web-inf, ("web-inf/jboss-deployment-structure.xml") where should I put it in the src folder?
我想在 web-inf 的根目录下有一个 xml 文件(“jboss-deployment-structure.xml”),(“web-inf/jboss-deployment-structure.xml”)我应该把它放在 src 的什么位置文件夹?
I tried creating "public/jboss-deployment-structure.xml" folder in src, but no luck.
我尝试在 src 中创建“public/jboss-deployment-structure.xml”文件夹,但没有运气。
回答by igonzalez
I had the same problem working with the Spring boot projects.
我在使用 Spring boot 项目时遇到了同样的问题。
This kind of project usually comes with embedded modules like Apache tomcat and prepared for use Spring annotations.
这类项目通常自带Apache tomcat等嵌入式模块,准备使用Spring注解。
For change configurations and make your web application easily configurable I suggest to create from scratch. See this url for more information:
为了更改配置并使您的 Web 应用程序易于配置,我建议从头开始创建。有关更多信息,请参阅此网址:
http://projects.spring.io/spring-boot/
http://projects.spring.io/spring-boot/
In my case I changed to:
就我而言,我改为:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
and I create my own structure.
我创建了自己的结构。
回答by cool
For a regular maven project if you need to have a structure of
对于常规 Maven 项目,如果您需要具有以下结构
target/WEB-INF/blabla.xml
then you should put
那么你应该把
src/main/resources/WEB-INF/blabla.xml
I hope that will help.
我希望这会有所帮助。
回答by J. Molinero
Maybe a little bit late, but in order to put your xml file inside WEB-INF, if you are using Maven, the correct placement will be:
也许有点晚了,但是为了将您的 xml 文件放在 WEB-INF 中,如果您使用的是 Maven,正确的位置将是:
src/main/webapp/WEB-INF/jboss-deployment-structure.xml