Springboot生产环境部署,外部配置文件
一、编写Springboot
二、开启配置文件
package com.citydo.properties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@EnableConfigurationProperties
@SpringBootApplication
public class PropertiesApplication {
public static void main(String[] args) {
SpringApplication.run(PropertiesApplication.class, args);
}
}
测试层
package com.citydo.properties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/test")
public class TestController {
@Value("${asr.name}")
private String name;
@RequestMapping(value = "/test")
public String test(){
return name;
}
}
三、Springboot打包在liunx生产服务器部署运行命令
nohup java -jar properties.jar --spring.config.location=../config/application.properties >error.log 2>&1 &
或者
java -jar properties.jar --spring.config.location=../config/application.properties >error.log 2>&1 &
生产服务器目录config放配置文件
接下来开始spring cloud一些总结,待续…