springboot系列4-简化部署

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ytuglt/article/details/83351635

1.导入生成可执行jar包的依赖

打开pom.xml文件,添加:

<!-- Package as an executable jar -->
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

2.打包

在这里插入图片描述

输出以下内容表示构建成功:

[INFO] Building jar: D:\work\workspace\springboot\spring-boot-01-helloworld\target\spring-boot-01-helloworld-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.6.RELEASE:repackage (default) @ spring-boot-01-helloworld ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.642 s
[INFO] Finished at: 2018-10-24T21:54:07+08:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

将目录下的D:\work\workspace\springboot\spring-boot-01-helloworld\target\spring-boot-01-helloworld-1.0-SNAPSHOT.jar 拷贝到测试目录,运行jar包:

	java -jar .\spring-boot-01-helloworld-1.0-SNAPSHOT.jar

浏览器中运行localhost:8080/hello测试,输出Hello world!

至此,部署成功~

猜你喜欢

转载自blog.csdn.net/ytuglt/article/details/83351635