首页  

springboot打包成可执行jar     所属分类 spring 浏览量 1402
配置 spring-boot-maven-plugin

https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/maven-plugin/usage.html



<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>true</fork>
					<mainClass>dyyx.Hello</mainClass>
					<layout>ZIP</layout>		
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>	
</build>





mvn package

java -jar springbootdemo-1.0.jar
java -jar xxx.jar --spring.profiles.active=dev

maven命令行运行项目

mvn spring-boot:run

mvn spring-boot:run -Dserver.port=8089



Hello.java import java.util.Date; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @SpringBootApplication public class Hello{ public static void main(String[] args) { SpringApplication.run(Hello.class, args); } @RequestMapping("/") public String home() { return "hello spring boot "+new Date(); } }

上一篇     下一篇
springboot2微服务实例

springcloud DiscoveryClient使用说明

maven知识点整理

springboot打包排除配置文件

springboot序列化异常FAIL_ON_EMPTY_BEANS处理

springboot应用打成war包