springBoot项目打包idea有什么方法

发布时间:2020-07-08 11:13:56 作者:清晨
来源:亿速云 阅读:160

小编给大家分享一下springBoot项目打包idea有什么方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

War包

1.首先在启动类继承SpringBootServletInitializer

@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(DemoApplication.class);
	}
	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
}

2.把项目pom文件改成war文件

<groupId>com.code</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

3.加入tomcat去猫依赖

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-tomcat</artifactId>
	<scope>provided</scope>
</dependency>

点击右键项目
然后点击OPen Module Settings(或者直接按F4)
点击Artifatcs ===》点击+号》Web Application:Exploded》点击from Modules…
然后再点击+号》Web Application:Archive》点击第二项
点击勾选Include in project build
点击右下角 Apply》OK
然后回主页点击工具栏中的Build》build Artifatcs ==》all Artifatcs ==》build
等待执行就成功啦
然后把打包好的项目放入tomcat中的webapp目录下,运行

Jar包

方法一

不用其他操作,直接
点击右键项目
然后点击OPen Module Settings(或者直接按F4)
点击Artifatcs ===》点击+号 ==》JAr》点击from Modules with dependencies…
然后弹出页面
在Main Class选中驱动类
在jar file from libraries 单选中 copy to the output directory and link via manifest,点击OK
点击勾选Include in project build
点击右下角 Apply》OK
然后回主页点击工具栏中的Build》build Artifatcs ==》all Artifatcs ==》build
等待执行就成功啦

把架包全部拷贝出来
使用命令
java -jar xxx.jar xxx为你的项目包名

方法二

点击右侧Maven projects
打开Lifecycle , 把上面闪电图标点亮
双击clean 清空原先的,成功后

双击package 等待执行打包成功

看完了这篇文章,相信你对springBoot项目打包idea有什么方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. Springboot项目打包并运行
  2. idea如何新建springboot项目

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

springboot 打包 idea

上一篇:部署WDS服务

下一篇:vue@cli3项目模板使用public目录下静态文件的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》