关于IDEA项目打包问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiewendong93/article/details/53024734

导出Jar包

<plugins>
         <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>1.6</source>
                  <target>1.6</target>
              </configuration>
          </plugin>
<plugins>

导出War包
该设置不正确通常会导致:
1, Tomcat成功启动,但是无法访问到静态页面,因为静态文件并没有在War包中
2, 亦或者是Controll不能找到JSP页面,因为WEB-INF不在War包中


以下是解决是我的解决方法
指定二个文件的路径,并设置War包内的目标路径
打包后我的War包结构为:
–static(静态文件)
–WEB-INF(lib,class,jsp)
按你自己的项目结构来打包


<packaging>war</packaging>
<build>
<plugins>
 <plugin>
       <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <webResources>
                <resource>
                    <!-- 以当前项目Pom路径为起点 web/WEB-INF -->
                    <directory>web/WEB-INF</directory>
                    <!-- 将WEB-INF下所有文件打包到包中WEB—INF下 -->
                    <targetPath>WEB-INF</targetPath>
                </resource>
                <resource>
                     <!-- 以当前项目Pom路径为起点 web/static -->
                    <directory>web/static</directory>
                    <!-- 目标路径 -->
                    <targetPath>static</targetPath>
                </resource>
            </webResources>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
</plugins>
</build>

猜你喜欢

转载自blog.csdn.net/xiewendong93/article/details/53024734