springboot+thymeleaf打war包在外部tomcat运行详解编程语言
2023-06-13 09:20:45 时间
工程目录
groupId org.springframework.boot /groupId artifactId spring-boot-starter-tomcat /artifactId scope provided /scope /dependency
groupId org.apache.maven.plugins /groupId artifactId maven-compiler-plugin /artifactId /plugin /plugins /build 配置文件application.properties
![springboot+thymeleaf打war包在外部tomcat运行详解编程语言](http://blog.ytso.com/zb_users/plugin/LazyLoad/usr/loading.gif)
pom文件注意点
packaging war /packaging
groupId org.springframework.boot /groupId artifactId spring-boot-starter-tomcat /artifactId scope provided /scope /dependency
groupId org.apache.maven.plugins /groupId artifactId maven-compiler-plugin /artifactId /plugin /plugins /build 配置文件application.properties
server.port=8013 server.session.timeout=3000 server.context-path=/prs #thymelea模板配置 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html spring.thymeleaf.mode=HTML5 spring.thymeleaf.encoding=UTF-8 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- >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
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/15686.html
cjavamysqlsqlserverxml
相关文章
- SpringBoot的启动流程_springboot启动卡住了
- springboot修改内置tomcat版本号_springboot整合消息队列
- Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包
- jenkins自动部署微服务与springboot项目【入门到精通-待更新】
- boot连接不上mysql数据库_关于springboot 连接mysql 数据库报错问题
- springboot解决乱码,你get到了吗
- SpringBoot项目|手把手快速搭建员工管理系统(附源码)
- springboot 配置JedisPool 简洁有效 复制即可运行「建议收藏」
- springboot详细讲解_Springboot项目
- springboot jdbc template_Springboot教程
- SpringBoot的JavaMailSender(邮件发送)接口使用
- SpringBoot源码分析系列之一:如何启动内嵌Tomcat
- springboot中配置tomcat的access log详解编程语言
- 服务安装安装Linux Tomcat服务,轻松管理Web应用程序(linux的tomcat)
- 的安装Linux下Tomcat的安装与配置(linux中tomcat)
- Springboot分布式限流实践详解编程语言
- Linux下一步步搭建Tomcat环境(linux配置tomcat环境变量)
- 轻松启动Tomcat:Linux环境的实现(linux怎么启动tomcat)
- 搭建Tomcat连接MySQL数据库的快速指南(tomcat连接mysql数据库)
- Linux部署Tomcat项目:一步一步步入正轨(linux部署tomcat项目)
- Linux下如何快速启动Tomcat(linux如何启动tomcat)
- Linux下启动Tomcat的简易指令(linux启动tomcat命令)
- Tomcat与MySQL助力Web应用程序开发(tomcat和mysql)
- 以Linux运行Tomcat,实现轻松部署Web应用(linux tomcat)