Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resource patterns in @PropertySource locations [SPR-16785] #21325

Closed
spring-projects-issues opened this issue May 1, 2018 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Pratapi Hemant Patel opened SPR-16785 and commented

Currently @PropertySource supports only absolute path

@PropertySource("classpath:prod/a.properties") // supported

But regex are not supported.

@PropertySource("classpath:prod/*.properties") // not supported

Affects: 4.3.16

Reference URL: https://stackoverflow.com/questions/50079355/add-all-properties-in-a-given-resources-folder-to-springs-environment-class

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Juergen Hoeller I have a user claiming this setup works for @Value. Do you know why that is?

@spring-projects-issues spring-projects-issues added the type: enhancement A general enhancement label Jan 11, 2019
@sbrannen sbrannen changed the title @PropertySource doesn't support regex paths like @PropertySource("classpath:prod/*.properties") [SPR-16785] @PropertySource doesn't support path patterns like @PropertySource("classpath:prod/*.properties") [SPR-16785] Jun 9, 2020
@sbrannen sbrannen changed the title @PropertySource doesn't support path patterns like @PropertySource("classpath:prod/*.properties") [SPR-16785] @PropertySource doesn't support path patterns like "classpath:prod/*.properties" [SPR-16785] Jun 9, 2020
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Jun 9, 2020
@sbrannen sbrannen modified the milestones: General Backlog, 5.3 M2 Jun 9, 2020
@sbrannen sbrannen changed the title @PropertySource doesn't support path patterns like "classpath:prod/*.properties" [SPR-16785] Support wildcard patterns in @PropertySource locations [SPR-16785] Jun 9, 2020
@sbrannen sbrannen added the status: pending-design-work Needs design work before any code can be developed label Jun 9, 2020
@jhoeller jhoeller modified the milestones: 5.3 M2, 5.3 RC1 Aug 8, 2020
@jhoeller jhoeller modified the milestones: 5.3 RC1, 5.x Backlog Aug 25, 2020
@tiagotds
Copy link

Any update regarding this subject?

@jhoeller jhoeller removed the status: pending-design-work Needs design work before any code can be developed label Aug 14, 2023
@jhoeller jhoeller self-assigned this Aug 14, 2023
@jhoeller jhoeller modified the milestones: 6.x Backlog, 6.1.0-M4 Aug 14, 2023
@sbrannen sbrannen changed the title Support wildcard patterns in @PropertySource locations [SPR-16785] Support resource patterns in @PropertySource locations [SPR-16785] Aug 16, 2023
@sbrannen sbrannen changed the title Support resource patterns in @PropertySource locations [SPR-16785] Support resource patterns in @PropertySource locations [SPR-16785] Aug 16, 2023
sbrannen added a commit that referenced this issue Aug 16, 2023
Inspired by the recently added support for resource patterns in
@propertysource locations, this commit adds the same support for
resource locations in @TestPropertySource.

For example, assuming the `config` folder in the classpath contains
only 3 files matching the pattern `file?.properties`,

... the following:

@TestPropertySource("classpath:/config/file1.properties")
@TestPropertySource("classpath:/config/file2.properties")
@TestPropertySource("classpath:/config/file3.properties")

... or:

@TestPropertySource({
    "classpath:/config/file1.properties",
    "classpath:/config/file2.properties",
    "classpath:/config/file3.properties"
})

... can now be replaced by:

@TestPropertySource("classpath*:/config/file?.properties")

See gh-21325
Closes gh-31055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants