Skip to content

Commit 59fca51

Browse files
authored
Bael 9329 - Spring Properties Cleaner (#18623)
* BAEL-9329 Example for Spring Properties Cleaner * Fix duplicates * Fix sorting * Fix prefixes * Add common file * Final version with all the properties fixed * Bump plugin version * With the comments and section split corrected
1 parent b1a0a85 commit 59fca51

File tree

7 files changed

+121
-0
lines changed

7 files changed

+121
-0
lines changed

maven-modules/maven-plugins/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<module>jaxws</module>
2222
<module>spotless</module>
2323
<module>external-properties-file</module>
24+
<module>spring-properties-cleaner</module>
2425
</modules>
2526

2627
<build>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>spring-properties-cleaner</artifactId>
7+
8+
<parent>
9+
<artifactId>maven-plugins</artifactId>
10+
<groupId>com.baeldung</groupId>
11+
<version>0.0.1-SNAPSHOT</version>
12+
</parent>
13+
14+
<dependencies>
15+
</dependencies>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>uk.org.webcompere</groupId>
21+
<artifactId>spring-properties-cleaner-plugin</artifactId>
22+
<version>1.0.6</version>
23+
<executions>
24+
<execution>
25+
<goals>
26+
<goal>scan</goal>
27+
</goals>
28+
</execution>
29+
</executions>
30+
<configuration>
31+
<!-- final configuration that protects these properties files - comment these all out and bring in the properties
32+
from "original-unfixed" to follow the steps from the example -->
33+
<sort>clustered</sort>
34+
<inlinePrefix>https?://</inlinePrefix>
35+
<common>full</common>
36+
<whitespace>section</whitespace>
37+
</configuration>
38+
</plugin>
39+
40+
<!-- the configuration below in not needed for this tutorial or for Spotless,
41+
but we need it when building all the modules in our Jenkins CI -->
42+
<plugin>
43+
<artifactId>maven-verifier-plugin</artifactId>
44+
<version>${maven.verifier.version}</version>
45+
<configuration>
46+
<verificationFile>../input-resources/verifications.xml</verificationFile>
47+
<failOnError>false</failOnError>
48+
</configuration>
49+
</plugin>
50+
</plugins>
51+
52+
<!-- in a spring project it will default to src/main/resources -->
53+
<resources>
54+
<resource>
55+
<directory>${project.basedir}/src/main/resources</directory>
56+
</resource>
57+
</resources>
58+
</build>
59+
60+
<properties>
61+
</properties>
62+
63+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring.redis.timeout=10000
2+
spring.jpa.show-sql=true
3+
4+
redis_host=http://localhost
5+
6+
upstream.host=http://myapp.dev.myorg.com
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
spring.redis.timeout=2000
2+
3+
upstream.host=https://myapp.prod.myorg.com
4+
5+
redis_host=https://azure.redis6a5d54.microsoft.com
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
spring.datasource.url=jdbc:postgresql://${db_server}/mydatabase
2+
spring.datasource.username=${USERNAME}
3+
spring.datasource.password=${PASSWORD}
4+
spring.redis.host=${redis_host}
5+
spring.redis.port=6379
6+
7+
# upstream services
8+
upstream.service.users.url=${upstream.host}/api/users
9+
upstream.service.products.url=${upstream.host}/api/products
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
spring.datasource.url=jdbc:postgresql://${db_server}/mydatabase
2+
spring.datasource.username=${USERNAME}
3+
spring.datasource.password = ${PASSWORD}
4+
5+
redis_host=localhost
6+
7+
spring.redis.host=http://${redis_host}
8+
spring.redis.port=6379
9+
10+
redis_host=localhost
11+
12+
spring.jpa.show-sql=true
13+
14+
15+
upstream.host = myapp.dev.myorg.com
16+
17+
# upstream services
18+
upstream.service.users.url=http://${upstream.host}/api/users
19+
upstream.service.products.url=http://${upstream.host}/api/products
20+
21+
spring.redis.timeout=10000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
spring.datasource.url=jdbc:postgresql://${db_server}/mydatabase
2+
spring.datasource.username=${USERNAME}
3+
spring.datasource.password = ${PASSWORD}
4+
5+
# upstream services
6+
upstream.service.users.url=https://${upstream.host}/api/users
7+
upstream.service.products.url=https://${upstream.host}/api/products
8+
9+
redis_host=azure.redis6a5d54.microsoft.com
10+
11+
spring.redis.host=https://${redis_host}
12+
spring.redis.port=6379
13+
14+
upstream.host = myapp.prod.myorg.com
15+
16+
spring.redis.timeout=2000

0 commit comments

Comments
 (0)