工程目录

pom文件注意点

<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<build>
<finalName>prs</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>

配置文件application.properties

server.port=
server.session.timeout=
server.context-path=/prs #thymelea模板配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
#spring.resources.chain.strategy.content.enabled=true
#spring.resources.chain.strategy.content.paths=/** # 上传文件大小配置
spring.http.multipart.maxFileSize=10MB
spring.http.multipart.maxRequestSize=10MB #spring.mvc.async.request-timeout=600000
#spring.http.multipart.max-request-size=200MB #spring.aop.auto=true
#spring.aop.proxy-target-class=false #server.tomcat.uri-encoding=UTF-8
#server.tomcat.max-threads=100
logging.config=classpath:logback.xml #mybatis.configLocation=classpath:mybatis/mybatis-config.xml
#mybatis.mapperLocations=classpath:mybatis/mapper/*.xml #spring.datasource.driverClassName = com.mysql.jdbc.Driver
#com.microsoft.sqlserver.jdbc.SQLServerDriver
#spring.datasource.url = jdbc:mysql://127.0.0.1:3306/test
#jdbc:sqlserver://104.15.202.101:1105;DatabaseName=tt
#spring.datasource.username = root
#spring.datasource.password = 123456 #spring.datasource.initialSize=2
#spring.datasource.minIdle=0
#spring.datasource.maxActive=5
#spring.datasource.maxWait=60000
#spring.datasource.validationQuery=select 1
#spring.datasource.timeBetweenEvictionRunsMillis=60000
#spring.datasource.testWhileIdle=true
#spring.datasource.testOnBorrow=true
#spring.datasource.testOnReturn=false
#spring.datasource.poolPreparedStatements=true
#spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
server.context-path=/prs这里的路径名最好和上面pom里的finalName最好是一致的,因为当我们把打包好的war包放到tomcat的webapp里时,访问路径前缀就是这个finalName

启动类

@ComponentScan(basePackages= {"com.wymessi"})//扫描组件
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableTransactionManagement(proxyTargetClass = true)
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class})
public class SpringbootApplication extends SpringBootServletInitializer { public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
} @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(SpringbootApplication.class);
} // @Bean
// public HttpMessageConverters fastJsonHttpMessageConverters() {
// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
// // fastJsonConfig.setSerializerFeatures(SerializerFeature.BrowserCompatible);
// // fastJsonConfig.setSerializerFeatures(SerializerFeature.BrowserSecure);
// fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
// // fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue);
// SerializeConfig config = new SerializeConfig();
// config.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
// fastJsonConfig.setSerializeConfig(config);
// fastConverter.setFastJsonConfig(fastJsonConfig);
// HttpMessageConverter<?> converter = fastConverter;
// return new HttpMessageConverters(converter);
// } }

和打jar包的区别是继承了SpringBootServletInitializer这个类,然后重写了configure方法。

运行程序

eclipse里运行

右击项目名,run as - spring boot app。

浏览器里输入http://127.0.0.1:8013/prs

打包成war包在tomcat里运行

右击项目名,run as - maven - build,看到success就代表打包成功了。

把打包好的prs放到tomcat的webapp里,然后启动tomcat。

这里要注意,tomcat的访问端口要设置成和配置文件里的一样,不然用配置文件里的port是访问不到的。

打包的名称要和server.context-path=/prs的名称一致,不然也是访问不到的,这个上面已经说过了。

浏览器里输入http://127.0.0.1:8013/prs

springboot+thymeleaf打war包在外部tomcat运行的更多相关文章

  1. SpringBoot之打成war包部署到Tomcat

    正常情况下SpringBoot项目是以jar包的形式,正常情况下SpringBoot项目是以jar包的形式,并且SpringBoot是内嵌Tomcat服务器,所以每次重新启动都是用的新的Tomcat服 ...

  2. springBoot项目打war包部署到tomcat上

    1 首先得在本地跑通. 2 处理启动类Application @SpringBootApplication public class Application extends SpringBootSer ...

  3. IDEA下spring boot项目打包war包部署外部tomcat问题

    第一步,修改配置pom.xml文件 <packaging>war</packaging> <dependency> <groupId>org.sprin ...

  4. SpringBoot webmvc项目导出war包并在外部tomcat运行产生的诸多问题以及解决方案

    背景: 有需求要将原来的Spring(3.2.6) + Springmvc + Hibernate项目重构为Springboot(1.5.2)项目 描述: 记录重构过程,以及期间遇到的种种问题和对应的 ...

  5. Springboot项目打成jar包运行 和 打成war包 外部tomcat运行

    Jar打包方式运行 类型为jar时 <packaging>jar</packaging> 1.使用命令mvn clean  package 打包 2.使用java –jar 包 ...

  6. 基于springboot多模块项目使用maven命令打成war包放到服务器上运行的问题

    首先,大家看到这个问题,可能并不陌生,而且脑子里第一映像就是使用mava中的clear package 或者 clear install进行打包,然后在项目中的target文件夹下面找到xxx.war ...

  7. SpringBoot打war包并部署到外部tomcat运行(jar工程改造为正war工程)

    如果你的SpringBoot工程是一个jar工程,而想把它改造成war工程,并打成war包放到外部的tomcat下运行,该怎么修改配置呢?这里以Maven工程为例进行介绍. (1)将pom.xml中的 ...

  8. SpringBoot 项目打war包 tomcat部署

    今天看了一下springboot的项目,个人习惯是接触新的语言或框架,首先要做的就是程序员届最常用的“Hello World”,然后进行项目部署,然今天部署却发现一直都是404,查看tomcat的we ...

  9. Springboot项目打成war包,部署到tomcat上,正常启动访问报错404

    前言: 项目介绍,此项目是一个Maven多模块项目,模块项目:all(父模块):util (公用的工具类):dao(实体类.业务类.mapper.mapper.xml):business(业务serv ...

随机推荐

  1. Codeforces #430 Div2 C

    #430 Div2 C 题意 给出一棵带点权的树,每一个节点的答案为从当前节点到根节点路径上所有节点权值的最大公因子(在求最大共因子的时候可以选择把这条路径上的任意一点的权值置为0).对于每一个节点单 ...

  2. 洛谷——P3913 车的攻击

    P3913 车的攻击 题目描述 N \times NN×N 的国际象棋棋盘上有KK 个车,第ii个车位于第R_iRi​行,第C_iCi​ 列.求至少被一个车攻击的格子数量. 车可以攻击所有同一行或者同 ...

  3. wildfly8.1部署注意事项

    wildfly8.1部署注意事项 jboss  最近新项目上线,本人部署过程中总结了以下几点比较关键的地方,看是否对大家有用处     服务器改成支持外网访问 在standalone.xml文件中找到 ...

  4. Oracle 后台进程

    一.基本后台进程       1.数据库写入进程(DBWn):       数据库写入程序讲数据库告诉缓存区中的修改块写入数据文件.对于多数系统来说,一个数据库写入程序(DBW0)就已经足够,但是对于 ...

  5. CodeForces - 986C AND Graph

    不难想到,x有边连出的一定是 (2^n-1) ^ x 的一个子集,直接连子集复杂度是爆炸的...但是我们可以一个1一个1的消去,最后变成补集的一个子集. 但是必须当且仅当 至少有一个 a 等于 x 的 ...

  6. 【贪心】【DFS】Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) C. Andryusha and Colored Balloons

    从任意点出发,贪心染色即可. #include<cstdio> #include<algorithm> using namespace std; int v[200010< ...

  7. 【最短路】【Heap-Dijkstra】【分层图】bzoj2662 [BeiJing wc2012]冻结

    裸的分层图最短路. #include<cstdio> #include<cstring> #include<queue> #include<algorithm ...

  8. Android中的动态字符串的处理

    1.效果显示 2. MainAcitivity.java package com.example.app2; import android.support.v7.app.AppCompatActivi ...

  9. SSH学习——Spring基础

    1.理解什么是Spring框架? spring是J2EE应用程序框架,是轻量级的IOC和AOP的容器框架,主要是针对javaBean的生命周期进行管理的轻量级容器,可以单独使用,也可以和Struts框 ...

  10. 微信开发之自定义菜单--weixin-java-tools

    一.前言 平时在开发微信的过程中,肯定会设计到微信的相关菜单的使用,这次就和大家介绍下如何使用weixin-java-tools来管理菜单 二.自定义菜单分类 1.click:点击推事件用户点击cli ...