Spring Boot solves the problem of third-party dependent jar packages

Projects built with Spring Boot + Maven need to introduce company-defined jar packages, which are not available in the maven central library.

At this point, there are two solutions.

The first: deploy the custom jar package into the maven library. But if there are too many third-party jar packages, it will be very troublesome;

 

The second: Like ordinary jar packages, introduce dependencies.

<dependency>
	<groupId>company_jar</groupId>
	<artifactId>company-self-sdk</artifactId>
	<version>1.0</version>
	<scope>system</scope>
	<systemPath>D:/sdk/company-self-sdk.jar</systemPath>
</dependency>

After the dependency is introduced in this way, there is no problem in coding, but when it is packaged into a war package, it will be found that the third-party jar package is not entered. At this time, you can add the following configuration under the build tag by modifying the pom.xml file:

<plugins>
	<plugin>
	   <groupId>org.apache.maven.plugins</groupId>
	   <artifactId>maven-war-plugin</artifactId>
	   <configuration>
		<webResources>
		   <resource>
			<directory>D:/sdk</directory>
			<targetPath>WEB-INF/lib/</targetPath>
			<includes>
			  <include>**/*.jar</include>
			</includes>
		  </resource>
		</webResources>
	  </configuration>
	</plugin>
</plugins>

 

If you want to make a jar package, you can add the following configuration under the build tag:

<resources>
	<resource>
		<directory>D:/sdk</directory>
		<targetPath>BOOT-INF/lib/</targetPath>
		<includes>
			<include>**/*.jar</include>
		</includes>
	</resource>
	<resource>
		<directory>src/main/resources</directory>
		<targetPath>BOOT-INF/classes/</targetPath>
	</resource>
</resources>

The purpose is to put the jar under the sdk folder of the D drive into BOOT-INF/lib, but a second resource must be added, otherwise the configuration file under src/main/resources will not be able to enter the jar package.

 

http://www.cnblogs.com/xiaosiyuan/p/6894766.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326314580&siteId=291194637