(1)pom.xml文件修改
4.0.0 springboot springboot0.0.1-SNAPSHOT war springboot Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent1.5.4.RELEASE UTF-8 UTF-8 1.7 org.springframework.boot spring-boot-starterorg.springframework.boot spring-boot-starter-loggingorg.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-testtest org.springframework.boot spring-boot-starter-thymeleaforg.springframework.boot spring-boot-starter-log4j1.3.8.RELEASE org.springframework.boot spring-boot-starter-data-redismysql mysql-connector-javaorg.mybatis.spring.boot mybatis-spring-boot-starter1.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安装参考:https://www.jb51.net/LINUXjishu/66536.html
Tomcat安装参考:https://www.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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



