添加多运行环境支持 #14
@@ -1,8 +1,6 @@
|
|||||||
package cn.celess.blog;
|
package cn.celess.blog;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
@@ -11,10 +9,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|||||||
@EnableAsync
|
@EnableAsync
|
||||||
@MapperScan("cn.celess.blog.mapper")
|
@MapperScan("cn.celess.blog.mapper")
|
||||||
public class BlogApplication {
|
public class BlogApplication {
|
||||||
public static final Logger logger = LoggerFactory.getLogger(BlogApplication.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(BlogApplication.class, args);
|
SpringApplication.run(BlogApplication.class, args);
|
||||||
logger.info("启动完成!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package cn.celess.blog.configuration;
|
||||||
|
|
||||||
|
import cn.celess.blog.entity.Config;
|
||||||
|
import cn.celess.blog.mapper.ConfigMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : xiaohai
|
||||||
|
* @date : 2020/10/16 16:00
|
||||||
|
* @desc :
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ApplicationListener implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ConfigMapper configMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("博客启动!");
|
||||||
|
List<Config> configurations = configMapper.getConfigurations();
|
||||||
|
configurations.forEach(config -> System.setProperty(config.getName(), config.getValue()));
|
||||||
|
log.debug("注入配置成功 {}", configurations.stream().map(Config::getName).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user