1.打成war发布tomcat是不是有资源路径问题?
修改application.properties文件 ; 添加: (sonicApplication,是对应war打包名)
server.servlet.context-path=/sonicApplication
2.如果用Thymeleaf 模板:修改html ,引用文件的方法,比如
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<link rel="stylesheet" th:href="@{/css/assets/bootstrap.min.css}">
<script th:src="@{/js/assets/jquery.js}"></script>
<img th:src="@{/img/logo_full.jpg}"/>
<script th:inline="javascript">
var ctx = [[@{/}]];
</script>
用ajax ctx是获取war名
$http({
method : "post",
url : ctx + "appJson/getSearch",
params : {"search": $scope.searchTest}
}).success(function (data) {
})
@ResponseBody
@RequestMapping("/getSearch")
public RestResultModule getSearch(
@RequestParam(name = "search",required = false,defaultValue = "")String search){
如果Tomcat下部署多个springboot项目,要在 application.yml 添加 , 不然会报错
spring:
# 多个springboot项目部署,需加
jmx:
enabled: false
springboot 发布外部tomcat : https://blog.youkuaiyun.com/weixin_38351566/article/details/83864259
不行留言.