How to pack resources in a Maven Project?

前端 未结 3 1718
独厮守ぢ
独厮守ぢ 2020-12-15 13:54

I am looking for suggestion in putting image file maven web project. One of classes under src/main/java need to use an image file. My problem is, if i put image file under s

3条回答
  •  孤城傲影
    2020-12-15 14:01

    The default resource directory for all Maven projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the WAR. The directory structure will be preserved in the process.

    .
     |-- pom.xml
     `-- src
         `-- main
             |-- java
             |   `-- com
             |       `-- example
             |           `-- projects
             |               `-- SampleAction.java
             |-- resources
             |   `-- images
             |       `-- sampleimage.jpg
             `-- webapp
                 |-- WEB-INF
                 |   `-- web.xml
                 |-- index.jsp
                 `-- jsp
                     `-- websource.jsp
    

    The suggested way to put your resources is in the src/main/resources

    Reference: Adding and Filtering External Web Resources

提交回复
热议问题