intellij idea打包springboot项目
一、可执行jar包
注意点:
- maven的package类型需要为jar
- 配置了spring-boot-mavne-plugin插件
1.1、pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.duchong.springboot</groupId>
<artifactId>springboot-learning</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot-learning</name>
<description>Learning project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
直接 Lifecycle--->package 即可生成可执行的jar
二、生成war包
注意点:
- 排除web-starter里面内置的tomcat ,如果本地要使用,可以单独加,scope为provided即可
- idea自动生成的ServletInitializer
- maven 的package类型为war
2.1、pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.duchong.springboot</groupId>
<artifactId>springboot-learning</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <name>springboot-learning</name>
<description>Learning project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
2.2、ServletInitializer类
package com.duchong.springboot; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer; public class ServletInitializer extends SpringBootServletInitializer { @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringbootLearningApplication.class);
} }
直接 Lifecycle--->package 即可生成war包
顺便吐槽一下,网上的有些关于打包的文章,真的是害人不浅,还是需要自己来摸索一遍的。
intellij idea打包springboot项目的更多相关文章
- gradle 打包springboot项目,找不到项目jar application.class
如题:gradle 打包springboot项目,找不到项目jar入口main方法:application.class 检查:lib/目录下没有相应项目的jar包 用gradle命令行查看日志:gra ...
- Intellij创建简单Springboot项目
Intellij创建简单Springboot项目 第一步:选择创建新项目——file-new-project 第二步:选择项目类型——Spring Initializr-next 第三步:输入项目信息 ...
- Intellij IDEA实现SpringBoot项目多端口启动的两种方法
有时候使用springboot项目时遇到这样一种情况,用一个项目需要复制很多遍进行测试,除了端口号不同以外,没有任何不同.遇到这种情况怎么办呢?这时候可以使用Intellij IDEA解决 前言 有时 ...
- Intellij IDEA实现SpringBoot项目多端口启动
前言 有时候使用springboot项目时遇到这样一种情况,用一个项目需要复制很多遍进行测试,除了端口号不同以外,没有任何不同.这时我们强大的Intellij IDEA就能替我们实现. 实现方法 第一 ...
- 使用IntelliJ Idea新建SpringBoot项目
简单给大家介绍一下我来创建SpringBoot项目使用的工具,本人使用IntelliJ Idea来创建项目,利用其中的Spring Initializr工具来快速创建项目. 步骤如下: 菜单栏中选择F ...
- intellij IDEA与springboot项目建立
概念问题: IntelliJ系中的Project相当于Eclipse系中的workspace.IntelliJ系中的Module相当于Eclipse系中的Project.IntelliJ中一个Proj ...
- 【Docker】Maven打包SpringBoot项目成Docker镜像并上传到Harbor仓库(Eclipse、STS、IDEA、Maven通用)
写在前面 最近,在研究如何使用Maven将SpringBoot项目打包成Docker镜像并发布到Harbor仓库,网上翻阅了很多博客和资料,发现大部分都是在复制粘贴别人的东西,没有经过实践的检验,根本 ...
- Jenkins 集成Maven打包SpringBoot项目并自动部署到Tomcat服务器
提前条件: 1.在Jenkins服务器上安装Git.JDK和Maven 2.准备另一台服务器并安装Tomcat 3.Gitlab服务器 4.Gitlab仓库中上传SpringBoot项目代码 第一步, ...
- intellij IDEA启动springboot项目报无效的源发行版错误解决方法
从http://start.spring.io/ 上下载的springboot 模板项目,导入intellij 后,报如下错误,原因是intellij 默认使用的Java compiler 是1.8版 ...
随机推荐
- RPM和yum相关
写在前面: 在这里可以知道rpm和yum的基本用法,找到更新本地yum源.搭建yum源的方法以及yum很琐碎的东西,包括yum源的优先级.用yum来安装或卸载CentOS图形界面包以及保存yum下载的 ...
- 使用roboware创建工作空间
1.打开终端,启动roboware软件: $roboware-studio 2.在欢迎使用的页面点新建工作区,工作区的名字建议写为:catkin_ws,路径放在home文件夹或者任意你想放的文件夹中. ...
- mogon操作数据库
返回的本来就是promise redis是内存数据库,更适合放session等一些东西.而mongo不是.
- SharedPreferences概述
SharedPreferences概述 一.简介 SharedPreferences简介 上图紫色标注的部分为使用方法. SharedPreferences成员(属性和方法) 二.核心函数及使用实例 ...
- SARG
SARG (Searchable Arguments)操作,因为它通常是指一个特定的匹配,一个值得范围内的匹配或者两个以上条件的AND连接. 中文名 SARG 全 称 Searchable ...
- WebUI 常用
//鼠标移动显示div //position:absolute这个是绝对定位:是相对于浏览器的定位.比如:position:absolute:left:20px;top:80px; 这个容器始终位于距 ...
- 在struts2.5版本中使用DMI遇到问题
struts2.5 为了提升安全性,添加了 allomethod 这么个玩意. 解决方法是在配置文件中添加: <package name="exam" extends=&qu ...
- MongoDB 高可用集群搭建(3.4)
一.架构概况192.168.56.101192.168.56.102192.168.56.103OS为centos 7.2 架构图: 规划5个组件对应的端口号,由于每台机器均需要同时部署 mong ...
- stl_hash_map.h
stl_hash_map.h // Filename: stl_hash_map.h // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: ...
- 安装Windows系统指南
安装系统指南 WIN10PE内核与WIN8PE内核区别: Win10PE内核支持NVME(M.2)新硬盘,WIN8PE不支持NVME. 但是WIN8PE对老机器的适配更好一些,其他功能均一致. 多一个 ...