0
# Resource Management
1
2
Automatic resource filtering and processing for Spring Boot applications, handling configuration files and static resources with intelligent filtering and encoding support.
3
4
## Capabilities
5
6
### Filtered Resources
7
8
Application configuration files that undergo property substitution during the build process.
9
10
```xml { .api }
11
/**
12
* Filtered resource configuration for Spring Boot configuration files
13
* Applies property substitution using configured delimiters
14
* Includes: application*.yml, application*.yaml, application*.properties
15
*/
16
<resource>
17
<directory>${basedir}/src/main/resources</directory>
18
<filtering>true</filtering>
19
<includes>
20
<include>**/application*.yml</include>
21
<include>**/application*.yaml</include>
22
<include>**/application*.properties</include>
23
</includes>
24
</resource>
25
```
26
27
**Usage Examples:**
28
29
```properties
30
# src/main/resources/application.properties
31
app.name=@project.name@
32
app.version=@project.version@
33
app.description=@project.description@
34
```
35
36
```yaml
37
# src/main/resources/application.yml
38
app:
39
name: '@project.name@'
40
version: '@project.version@'
41
build-time: '@maven.build.timestamp@'
42
```
43
44
### Non-Filtered Resources
45
46
Static resources that should not undergo property substitution to preserve their original content.
47
48
```xml { .api }
49
/**
50
* Non-filtered resource configuration for static assets
51
* Excludes configuration files from filtering to prevent corruption
52
* Includes: All resources except application configuration files
53
*/
54
<resource>
55
<directory>${basedir}/src/main/resources</directory>
56
<excludes>
57
<exclude>**/application*.yml</exclude>
58
<exclude>**/application*.yaml</exclude>
59
<exclude>**/application*.properties</exclude>
60
</excludes>
61
</resource>
62
```
63
64
**Usage Examples:**
65
66
Static files that remain unchanged during build:
67
- `src/main/resources/static/css/styles.css`
68
- `src/main/resources/templates/index.html`
69
- `src/main/resources/data/sample.json`
70
- `src/main/resources/certificates/keystore.jks`
71
72
### Resource Plugin Configuration
73
74
Maven resources plugin configuration with encoding and delimiter settings.
75
76
```xml { .api }
77
/**
78
* Maven resources plugin configuration
79
* Controls encoding and property substitution behavior
80
*/
81
<plugin>
82
<groupId>org.apache.maven.plugins</groupId>
83
<artifactId>maven-resources-plugin</artifactId>
84
<configuration>
85
<propertiesEncoding>${project.build.sourceEncoding}</propertiesEncoding>
86
<delimiters>
87
<delimiter>${resource.delimiter}</delimiter>
88
</delimiters>
89
<useDefaultDelimiters>false</useDefaultDelimiters>
90
</configuration>
91
</plugin>
92
```
93
94
## Resource Filtering Patterns
95
96
### Property Substitution
97
98
```properties
99
# Before filtering (in source)
100
server.port=@server.port@
101
app.name=@project.name@
102
build.version=@project.version@
103
104
# After filtering (in target)
105
server.port=8080
106
app.name=my-spring-app
107
build.version=1.0.0
108
```
109
110
### Profile-Specific Resources
111
112
```yaml
113
# application.yml
114
app:
115
name: '@project.name@'
116
profile: '@spring.profiles.active@'
117
118
# application-dev.yml
119
server:
120
port: 8080
121
122
# application-prod.yml
123
server:
124
port: 80
125
```
126
127
### Complex Property Substitution
128
129
```yaml
130
# Source configuration
131
database:
132
url: 'jdbc:postgresql://@db.host@:@db.port@/@db.name@'
133
username: '@db.username@'
134
password: '@db.password@'
135
136
# Maven properties (in pom.xml or profiles)
137
<properties>
138
<db.host>localhost</db.host>
139
<db.port>5432</db.port>
140
<db.name>myapp</db.name>
141
<db.username>appuser</db.username>
142
<db.password>secret</db.password>
143
</properties>
144
```
145
146
## Resource Directory Structure
147
148
```
149
src/
150
└── main/
151
└── resources/
152
├── application.yml # Filtered
153
├── application-dev.yml # Filtered
154
├── application-prod.yml # Filtered
155
├── application.properties # Filtered
156
├── static/ # Not filtered
157
│ ├── css/
158
│ ├── js/
159
│ └── images/
160
├── templates/ # Not filtered
161
│ └── index.html
162
├── data/ # Not filtered
163
│ └── initial-data.sql
164
└── META-INF/ # Not filtered
165
└── spring.factories
166
```