1
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package cn.van;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
* @version 1.0
|
||||
@@ -14,7 +18,22 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
|
||||
private final Environment env;
|
||||
|
||||
public Application(Environment env) {
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
String[] activeProfiles = env.getActiveProfiles();
|
||||
if (activeProfiles.length == 0) {
|
||||
activeProfiles = env.getDefaultProfiles();
|
||||
}
|
||||
System.out.println("Active profiles: " + Arrays.toString(activeProfiles));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user