美文网首页
springboot 的部署前准备

springboot 的部署前准备

作者: 逸曦穆泽 | 来源:发表于2019-03-07 18:39 被阅读0次

1、在启动的 Application 中注册静态文件访问路径,开发或部署的静态资源

@Bean
public WebMvcConfigurer webMvcConfigurer() {
     return new WebMvcConfigurer() {
          @Override
          public void addResourceHandlers(ResourceHandlerRegistry registry) {              
registry.addResourceHandler("/upload/**").addResourceLocations("file:/usr/project/upload/");
 //registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/upload/"); registry.addResourceHandler("/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/static/");
          }
      };
}

2、打出完整的 jar 包,解压该xxx.jar包,找到BooT-INF文件夹打开,将文件夹下的lib文件夹拷贝一份,放到与服务器部署xxx.jar(不带lib文件的)的同级目录下;

3、打出不带lib的jar包(xxx.jar) ==>在 pom.xml 中的 build ->plugins->plugin下添加:

 <configuration>
   <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> 
   <mainClass>com.lenze.ssm.LenzeMgApplication</mainClass>
   <layout>ZIP</layout>
     <includes>
       <include>
     <groupId>nothing</groupId>
     <artifactId>nothing</artifactId>
    </include>
      </includes> 
    </configuration>
  <executions>
    <execution>
      <goals>
        <goal>repackage</goal>
      </goals>
    </execution>
 </executions>  

4、常驻云服务器

nohup :是不挂服务、常驻;

&:表示执行命令后要生成日志文件nohup.out文件;

Windows:

nohup java -Dloader.path=D:/path/lib -jar D:/path/xxx.jar &

Linux:

nohup java -Dloader.path=/path/lib -jar /path/xxx.jar &

语法:

nohup java -Dloader.path=/路径/lib -jar /路径/xxx.jar
(比如:nohup java -Dloader.path=/usr/project/lib -jar /usr/project/pro-1.0.0.jar >/dev/null 2>&1 &)

5、解决清空nohup.out日志问题:

命令:

①cp/dev/null nohup.out
②cat/dev/null > nohup.out

运行:(语法:nohup java -jar xxx.jar >/dev/null 2>&1 &)

nohup java -Dloader.path=/路径/lib -jar /路径/xxx.jar >/dev/null 2>&1 &

(比如:nohup java -Dloader.path=/usr/project/lib -jar /usr/project/pro-1.0.0.jar >/dev/null 2>&1 &)

相关文章

网友评论

      本文标题:springboot 的部署前准备

      本文链接:https://www.haomeiwen.com/subject/rtqiuqtx.html