Maven打成Webjar并使用的方法

1.编写pom.xml

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.asiainfo</groupId>
  <artifactId>edot-phone-app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>edot-phone-app Maven Webapp</name>
  <url>http://maven.apache.org</url>
  
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <destDir>${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version}</destDir>
  </properties>
  
  <build>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/webapp</directory>
        <targetPath>${destDir}</targetPath>
      </resource>
    </resources>
  </build>

</project>

2.执行命令deploy

3.applicationContext-mvc.xml

增加<mvc:resourcesmapping="/webjars/**"location="classpath:/META-INF/resources/webjars/"/>

参考博文:http://blog.csdn.net/sxdtzhaoxinguo/article/details/45666789

相关推荐