其他maven源文件夹,如src/main/javascript或src/main/css?

ant*_*lma 4 java directory maven

我一直在开发一个标准的Web应用程序,让Eclipse显示src/main/resources和src/main/java这样一个方便的平面包方式真的很烦人,但我不得不经常深入到src/main/webapp及其所有子目录,以修改我的css,js和html文件.

我从来没有见过一个项目使用额外的源文件夹来获取这些资源,但尝试是不可能的吗?理想情况下,我希望有一个类似的目录结构

src/main/java
src/main/resources
src/main/jsp
src/main/javascript
src/main/css
Run Code Online (Sandbox Code Playgroud)

有没有人设置这样的项目?即使尝试破坏现有的插件等等,是否会变得更麻烦?

Grz*_*Żur 7

以这种方式添加资源文件夹

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory>resource1</directory>
     </resource>
     <resource>
       <directory>resource2</directory>
     </resource>
     <resource>
       <directory>resource3</directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>
Run Code Online (Sandbox Code Playgroud)

更多信息

但是,如果您需要多个Web资源(WEB-INFWAR文件中的目录),则需要配置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>
Run Code Online (Sandbox Code Playgroud)