栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

jenkins 自动部署 springboot项目war包到tomcat容器 图文详解

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jenkins 自动部署 springboot项目war包到tomcat容器 图文详解

系统设置->全局工具配置

Maven 配置
选择自已的setting配置文件

JDK 安装
指定自己的jdk目录

Git
指定自己的git,如果系统已经安装,会自动检测到

Maven
指定自己的maven目录

准备发布tomcat的war包

添加帮助类

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class RenrenApplicationWeb extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(RenrenApplicationWeb.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(RenrenApplication.class);
	}
}

pom依赖
provided指定tomcat相关jar包不会打包进war,使用容器的jar包


	org.springframework.boot
	spring-boot-starter-web
	
		
			org.springframework.boot
			spring-boot-starter-tomcat
		
	


	org.springframework.boot
	spring-boot-starter-tomcat
	provided

finalName指定war包的名称,也是容器的访问路径


	generator
	
		
			org.springframework.boot
			spring-boot-maven-plugin
		
	

tomcat配置

修改端口
修改apache-tomcat-8.5.34confserver.xml文件
这里把8080修改成了8089


新增用户

修改apache-tomcat-8.5.34conftomcat-users.xml文件

以下为tomcat内置的管理角色
Built-in Tomcat manager roles:
    - manager-gui    - allows access to the HTML GUI and the status pages
    - manager-script - allows access to the HTTP API and the status pages
    - manager-jmx    - allows access to the JMX proxy and the status pages
    - manager-status - allows access to the status pages only

新增用户tomcat_user并给他管理角色权限,这样jenkins才能把war包发布到tomcat容器中






新建item并配置

构建一个maven项目

如果没有构建一个maven项目选项,请下载Maven Integration plugin




mvn clean package -Dmaven.test.skip=true -P dev


至此部署完成,点击构建自动部署
访问http://localhost:8089/generator/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/893922.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号