SpringBoot war包部署到Tomcat服务器

网友投稿 234 2023-02-10


SpringBoot war包部署到Tomcat服务器

(1)pom.xml文件修改war,默认是jar包,节点中增加springboot,即生成war包的名字,完整pohttp://m.xml文件内容如下:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

springboot

springboot&lhttp://t;/artifactId>

0.0.1-SNAPSHOT

war

springboot

Demo project for Spring Boot

org.springframework.boot

spring-boot-starter-parent

1.5.4.RELEASE

UTF-8

UTF-8

1.7

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-logging

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-starter-thymeleaf

org.springframework.boot

spring-boot-starter-log4j

1.3.8.RELEASE

org.springframework.boot

spring-boot-starter-data-redis

mysql

mysql-connector-java

org.mybatis.spring.boot

mybatis-spring-boot-starter

1.1.1

springboot

org.springframework.boot

spring-boot-maven-plugin

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

springboot

springboot&lhttp://t;/artifactId>

0.0.1-SNAPSHOT

war

springboot

Demo project for Spring Boot

org.springframework.boot

spring-boot-starter-parent

1.5.4.RELEASE

UTF-8

UTF-8

1.7

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-logging

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-starter-thymeleaf

org.springframework.boot

spring-boot-starter-log4j

1.3.8.RELEASE

org.springframework.boot

spring-boot-starter-data-redis

mysql

mysql-connector-java

org.mybatis.spring.boot

mybatis-spring-boot-starter

1.1.1

springboot

org.springframework.boot

spring-boot-maven-plugin

(2)修改项目启动类,继承SpringBootServletInitializer,如下:

package springboot;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.support.SpringBootServletInitializer;

import org.springframework.cache.annotation.EnableCaching;

import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication

@EnableScheduling

@EnableCaching

public class SpringbootApplication extends SpringBootServletInitializer{

public static void main(String[] args) {

SpringApplication.run(SpringbootApplication.class, args);

}

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

return application.sources(SpringbootApplication.class);

}

}

(3)打包:可以通过eclipse run as ->maven install,也可以进入项目的根目录,也就是pom.xml同一级目录,启动cmd控制台,执行mvn install package,如下:

(4)环境搭建(linux环境JDK安装与Tomacat安装(springboot支持tomcat7以上))

JDK安装参考://jb51.net/LINUXjishu/66536.html

Tomcat安装参考://jb51.net/article/95272.htm

(5)将打包好的war包上传至tomcat目录下webapp目录下,启动tomcat服务器。

(6)访问项目路径:http://ip地址:端口号/项目打包名称/方法名(项目打包名称即pom.xml中的的值)

(7)设置tomcat开机自动启动

(1)修改脚本文件rc.local:vim /etc/rc.d/rc.local

(2)在rc.local中增加:export JAVA_HOME = jdk安装路径 ,tomcat安装路径/bin/startup.sh start


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序实现全局搜索代码高亮的示例
下一篇:Java实现RSA算法的方法详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~