fourcal/src/main/java/cn/palmte/work/FourCalApplication.java

41 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package cn.palmte.work;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import java.util.HashMap;
import java.util.Map;
/**
* 四算项目
*/
@SpringBootApplication
public class FourCalApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(FourCalApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
/**
* war包运行的话为了不修改配置文件在运行的tomcat的catalina.sh中添加jvm参数-Dspring.profiles.active=test
* 因为我们现在已经有一个env了所以可以根据这个设置profile
* 命令行java -jar运行的话直接通过-Dspring.profiles.active=test来指定
*/
setRegisterErrorPageFilter(false);
String env = System.getProperty("env");
if (null != env) {
Map<String, Object> map = new HashMap<>(1);
map.put("spring.profiles.active", env);
builder.properties(map);
//不能使用 builder.profiles(env);否则可能出现两个环境的都配置了
}
return builder.sources(FourCalApplication.class);
}
}