标签:ptr work roc target container org val article app
pom文件中packaging:
//命令打包(-Dmaven.test.skip=true 跳过测试)
mvn clean package -Dmaven.test.skip=true或者执行Maven install
#启动命令
nohub java -jar xxxx.jar >/dev/null 2>&1 &
<!-- <packaging>jar</packaging> -->
<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 移除之后会报错,加入下面的依赖 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
2、修改启动类
package top.lrshuai.blog;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.http.HttpStatus;
@SpringBootApplication
@MapperScan("top.lrshuai.blog.dao")
public class Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// TODO Auto-generated method stub
// return super.configure(builder);
return builder.sources(this.getClass());
}
}
mvn clean package -Dmaven.test.skip=true
mvn clean install -Dmaven.test.skip=true
)<link href="/css/blog.css" rel="stylesheet" >
就可以了,打包jar 我记得好像是没问题的,但是war就出问题了<link href="../static/css/blog.css" rel="stylesheet" th:href="@{/css/blog.css}">
<meta name="_ctx" th:content="@{/}" />
<script type="text/javascript">
var _ctx = $("meta[name=‘_ctx‘]").attr("content");
_ctx = _ctx.substr(0, _ctx.length - 1);
</script>
_ctx
。比如:url = "/article/add"
就改为url = ctx+"/article/add"
标签:ptr work roc target container org val article app
原文地址:https://www.cnblogs.com/xianshiwang/p/9064470.html