Springboot生产环境部署,外部配置文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32447301/article/details/83187732

一、编写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一些总结,待续…

猜你喜欢

转载自blog.csdn.net/qq_32447301/article/details/83187732