무중단 배포 테스트중
This commit is contained in:
31
src/main/java/myblog/blog/main/ProfileController.java
Normal file
31
src/main/java/myblog/blog/main/ProfileController.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package myblog.blog.main;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class ProfileController {
|
||||
|
||||
private final Environment env;
|
||||
|
||||
@GetMapping("/profile")
|
||||
public String profile(){
|
||||
List<String> profiles = Arrays.asList(env.getActiveProfiles());
|
||||
|
||||
List<String> realProfiles = Arrays.asList("real", "real1", "real2");
|
||||
|
||||
String defaultProfile = profiles.isEmpty()? "default" : profiles.get(0);
|
||||
|
||||
return profiles.stream()
|
||||
.filter(realProfiles::contains)
|
||||
.findAny()
|
||||
.orElse(defaultProfile);
|
||||
}
|
||||
|
||||
}
|
||||
6
src/main/resources/application-real1.yml
Normal file
6
src/main/resources/application-real1.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
server:
|
||||
port: 8081
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
include: dev
|
||||
6
src/main/resources/application-real2.yml
Normal file
6
src/main/resources/application-real2.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
server:
|
||||
port: 8082
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
include: dev
|
||||
Reference in New Issue
Block a user