spring-boot-dependencies jar 不完整的问题

集成 springboot 有两种方式。

1 直接 父项目指向  springboot 

  

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.3.RELEASE</version>
	</parent>

  这种用起来很方便 ,默认打出的jar 也是完整的。

2 使用  spring-boot-dependencie 

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

  这种默认打出的jar包是不完整的。 不能直接运行。

加入下面的配置就可以了

	<build>
	    <plugins>
	        <plugin>
	            <groupId>org.springframework.boot</groupId>
	            <artifactId>spring-boot-maven-plugin</artifactId>
	            <configuration>
	                <mainClass>com.sbl.pay.subaccount.SubaccountServerRunner</mainClass>
	            </configuration>
	            <executions>
	                <execution>
	                    <goals>
	                        <goal>repackage</goal>
	                    </goals>
	                </execution>
	            </executions>
	        </plugin>
	    </plugins>
	</build>

  

第二种麻烦一点,但是我们可以使用自己的父类。

猜你喜欢

转载自www.cnblogs.com/cxygg/p/9559618.html
今日推荐