简体   繁体   中英

Intellij idea build artifact no js and css file copied

Project Structure When I build artifact or run the tomcat in Idea,only .ftl files are copied. The .css and .js file won't be copied.I have to copy them to the out put directory manually.

Out put Layout Anything wrong with my settings? Thanks.

Please, make sure that your servlet-context.xml or web.xml, has as follows

  <!-- Additional file type mappings -->
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.ico</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
  </servlet-mapping>


  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
  </servlet-mapping>

Finally solved this problem. *.js and *.css files are excluded from artifact in my pom configuration . I thought pom.xml configuration is for maven build only and Idea uses its own builtin build system before. my configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <warName>${project.artifactId}</warName>
            <failOnMissingWebXml>true</failOnMissingWebXml>
            <warSourceExcludes>**/*.js,**/*.css</warSourceExcludes>
        </configuration>
    </plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM