简体   繁体   English

Intellij Idea构建工件没有复制js和css文件

[英]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. 项目结构当我构建构件或在Idea中运行tomcat时,仅复制.ftl文件。 The .css and .js file won't be copied.I have to copy them to the out put directory manually. .css和.js文件不会被复制。我必须手动将它们复制到输出目录。

Out put Layout Anything wrong with my settings? 输出布局我的设置有问题吗? Thanks. 谢谢。

Please, make sure that your servlet-context.xml or web.xml, has as follows 请确保您的servlet-context.xml或web.xml具有以下内容

  <!-- 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 . * .js和* .css文件从我的pom配置中的工件中排除。 I thought pom.xml configuration is for maven build only and Idea uses its own builtin build system before. 我认为pom.xml配置仅适用于maven构建,而Idea之前使用其自己的内置构建系统。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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