Maven packaging projects are dependent packages and package references

One: maven configuration

1.1, the original configuration

insert image description here

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
				<mainClass>SecretApplication</mainClass>
			</configuration>
		</plugin>
	</plugins>
</build>

Maven is packaged, and the jar package is as follows:
insert image description here

1.2. Change configuration

insert image description here

<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
			</configuration>
		</plugin>
		<!--<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
				<mainClass>SecretApplication</mainClass>
			</configuration>
		</plugin>-->
	</plugins>
</build>

Maven repackages the jar package as follows:
insert image description here
the jar package can provide third-party references.

Two: jar package reference

Take the above jar package as an example: secret-1.0.0.jar

2.1. Introduce maven warehouse

You can put the jar package into your own maven warehouse and import it through the pom file

<dependency>
	<groupId>secret</groupId>
	<artifactId>secret</artifactId>
	<version>1.0.0</version>
</dependency>

2.2. Manual introduction (more convenient)

Create a lib directory in the root directory of the project, and place (secret-1.0.0.jar) in this directory.
Configure in the pom file

<dependency>
    <groupId>secret</groupId>
    <artifactId>secret</artifactId>
    <version>1.0.0</version>
    <scope>system</scope>
    <systemPath>${
    
    project.basedir}/lib/secret-1.0.0.jar</systemPath>
</dependency>

Guess you like

Origin blog.csdn.net/qq_38254635/article/details/131800967