Skip to content

Commit 71af6ee

Browse files
committed
add example for Spring Boot profiles
1 parent b8e0845 commit 71af6ee

28 files changed

+598
-1
lines changed

build-all.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ MAIN_DIR=$PWD
44

55
build_gradle_module() {
66
MODULE_PATH=$1
7+
echo ""
78
echo "+++"
89
echo "+++ BUILDING MODULE $MODULE_PATH"
910
echo "+++"
@@ -12,15 +13,16 @@ build_gradle_module() {
1213
./gradlew clean build --info --stacktrace
1314
if [ $? -ne 0 ]
1415
then
16+
echo ""
1517
echo "+++"
1618
echo "+++ BUILDING MODULE $MODULE_PATH FAILED"
1719
echo "+++"
1820
exit 1
1921
else
22+
echo ""
2023
echo "+++"
2124
echo "+++ BUILDING MODULE $MODULE_PATH SUCCESSFUL"
2225
echo "+++"
23-
echo ""
2426
fi
2527
cd $MAIN_DIR
2628
}
@@ -48,6 +50,7 @@ build_gradle_module "spring-boot/starter"
4850
build_gradle_module "spring-boot/startup"
4951
build_gradle_module "spring-boot/static"
5052
build_gradle_module "spring-boot/validation"
53+
build_gradle_module "spring-boot/profiles"
5154
build_gradle_module "spring-cloud/feign-with-spring-data-rest"
5255
build_gradle_module "spring-cloud/sleuth-downstream-service"
5356
build_gradle_module "spring-cloud/sleuth-upstream-service"
@@ -57,6 +60,7 @@ build_gradle_module "spring-data/spring-data-rest-associations"
5760
build_gradle_module "spring-data/spring-data-rest-springfox"
5861
build_gradle_module "tools/jacoco"
5962

63+
echo ""
6064
echo "+++"
6165
echo "+++ ALL MODULES SUCCESSFUL"
6266
echo "+++"

spring-boot/profiles/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**
6+
!**/src/test/**
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
17+
### IntelliJ IDEA ###
18+
.idea
19+
*.iws
20+
*.iml
21+
*.ipr
22+
out/
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
31+
### VS Code ###
32+
.vscode/

spring-boot/profiles/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plugins {
2+
id 'org.springframework.boot' version '2.2.2.RELEASE'
3+
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
4+
id 'java'
5+
}
6+
7+
group = 'io.reflectoring'
8+
version = '0.0.1-SNAPSHOT'
9+
sourceCompatibility = '11'
10+
11+
repositories {
12+
mavenCentral()
13+
}
14+
15+
dependencies {
16+
implementation 'org.springframework.boot:spring-boot-starter'
17+
testImplementation('org.springframework.boot:spring-boot-starter-test') {
18+
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
19+
}
20+
}
21+
22+
test {
23+
useJUnitPlatform()
24+
}
54.9 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

spring-boot/profiles/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot/profiles/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'profiles'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.reflectoring.profiles;
2+
3+
import javax.annotation.PostConstruct;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.context.annotation.Profile;
7+
import org.springframework.stereotype.Component;
8+
9+
class BarBean {
10+
11+
private static final Logger logger = LoggerFactory.getLogger(BarBean.class);
12+
13+
@PostConstruct
14+
void postConstruct(){
15+
logger.info("loaded BarBean!");
16+
}
17+
18+
}

0 commit comments

Comments
 (0)