Spring Boot 不使用默认的parent,改用自己项目的 parent

引言

今天项目中遇到一个问题,由于之前指定了公司二方包版本,后来这些部门升级了版本,使得部分rpc调用出现了异常,各种报错,今天需要将项目的版本由二方包版本统一管理。

下面就简单的记录了一下问题的解决方法,以便后续使用。


pom.xml文件中

解决方法

1.删掉默认继承的spring-boot-starter-parent 这个parent

2.添加如下声明:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.2.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

3.修改spring-boot-maven-plugin为如下:

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>2.1.1.RELEASE</version>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

问题完美解决

如果有对

<dependencyManagement>和dependency不熟的小伙伴,可以查看下面的文章。

parent和dependency和dependencyManagement

Guess you like

Origin blog.csdn.net/qq_29235677/article/details/120452855