1.WEB-INF文件夹下添加lib文件夹,文件夹下添加demo-client-0.1-SNAPSHOT.jar
2.pom.xml中配置如下代码:
1 <dependency> 2 <groupId>com.ali.demo.sso</groupId> 3 <artifactId>demo-common-resource</artifactId> 4 <version>0.1-resource-SNAPSHOT</version> 5 <scope>system</scope> 6 <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/demo-client-0.1-SNAPSHOT.jar</systemPath> 7 </dependency>
system scope引入的包,在使用jar-with-dependencies打包时将不会被包含,可以使用resources将本地包打进jar-with-dependencies
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>xxx-jar-with-dependencies</finalName> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <targetPath>lib/</targetPath> <directory>lib/</directory> <includes> <include>**/demo-client-0.1-SNAPSHOT.jar</include> </includes> </resource> </resources> </build>
生成的xxx-jar-with-dependencies.jar中,将会包含lib目录以及demo-client-0.1-SNAPSHOT.jar,并且能够被在执行的时候被找到。