Skip to content

[validation] @Value annotations with classpath should be of type Resource or similar #1581

Closed

Description

@martinlippert

For code snippets like:

@Value("classpath:somefile.txt")
private Resource myFile;

a validation could run to make sure that - if the @Value annotation points to a resource (e.g. classpath: in this case), that the type if the annotated element (field, parameter) is of type Resource. Otherwise, this might lead to unwanted behavior. E.g. if the type if the field is String, the name of the resource is being injected instead of the content of the file.

Activity

  1. added this to the Backlog milestone on Jun 16, 2025
  2. added
    for: eclipse
    for: vscode
    on Jun 16, 2025
  3. martinlippert commented on Jun 16, 2025

    @martinlippert
    MemberAuthor

    The corresponding quick fix to change the type of the annotated element could also be offered here.

  4. martinlippert commented on Jun 24, 2025

    @martinlippert
    MemberAuthor

    Actually, the field should be of type. Resource or File, both works just fine.

  5. added a commit that references this issue on Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: eclipsefor: vscodetheme: validationtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions