[英]Additional maven source folders such as src/main/javascript or src/main/css?
I've been developing a standard web app and its really annoying to have Eclipse show src/main/resources and src/main/java in such a convenient flat-package way, yet I have to frequently drill down into src/main/webapp and all its subdirectories to modify my css, js, and html files. 我一直在开发一个标准的Web应用程序,让Eclipse以一种方便的平面包方式显示src / main / resources和src / main / java真的很烦人,但我不得不经常深入到src / main / webapp及其所有子目录,以修改我的css,js和html文件。
I've never seen a project use additional source folders for resources like those, but is it out of the question to try? 我从来没有见过一个项目使用额外的源文件夹来获取这些资源,但尝试是不可能的吗? Ideally I'd love to have a directory structure like 理想情况下,我希望有一个类似的目录结构
src/main/java
src/main/resources
src/main/jsp
src/main/javascript
src/main/css
Has anyone setup a project like this? 有没有人设置这样的项目? Does it become more of a hassle to even try, breaking existing plugins and whatnot? 即使尝试破坏现有的插件等等,是否会变得更麻烦?
Add resource folders this way. 以这种方式添加资源文件夹
<project>
...
<build>
...
<resources>
<resource>
<directory>resource1</directory>
</resource>
<resource>
<directory>resource2</directory>
</resource>
<resource>
<directory>resource3</directory>
</resource>
</resources>
...
</build>
...
</project>
However, if you want multiple web resources ( WEB-INF
directory in WAR file) than you need to configure Maven War plugin . 但是,如果您需要多个Web资源(WAR文件中的WEB-INF
目录),则需要配置Maven War插件 。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>src/main/jsp</directory>
</resource>
<resource>
<directory>src/main/javascript</directory>
</resource>
<resource>
<directory>src/main/css</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.