Skip to content

[spring framework 7] add validation + quickfixes to identify new BeanRegistrars that are not imported #1499

Closed

Description

@martinlippert

The new way to register beans in a functional way is coming to Spring Framework 7:
spring-projects/spring-framework#18353 (comment)

We need to add a new validation:

  • for every class that implements BeanRegistrar, there should be an @Import(..) for that class in some configuration
  • quick fix should allow users to add this @Import to existing configuration classes, or create a new configuration class with that @Import
    • difficulty might be that a config class already has an @Import annotation, in which case the bean registrar type should be added to that @Import annotation for that config class
@Configuration
@Import(MyBeanRegistrar.class)
public class MyConfiguration {
}

public class MyBeanRegistrar implements BeanRegistrar {
...

Activity

  1. added
    for: eclipse
    for: vscode
    on Mar 4, 2025
  2. added this to the 4.30.0.RELEASE milestone on Mar 4, 2025
  3. added 2 commits that reference this issue on Mar 12, 2025
  4. BoykoAlex commented on Mar 17, 2025

    @BoykoAlex
    Contributor

    @martinlippert I have pushed 7df37a3.

    As expected now there are issues observed once the quick fix is applied since there is nothing to kick off re-validation... I'm thinking of adding dependency files for BeanRegistrar bean files. Namely, I'm thinking of configuration bean resources to be dependencies of BeanRegistrar resources. Consequently a change in configuration bean resource would trigger re-indexing and re-validation of the BeanRegistrar resource

  5. martinlippert commented on Mar 19, 2025

    @martinlippert
    MemberAuthor

    I have tested this with the latest from main, but I see a lot of false positives here.

    • I have a BeanRegistrar implementation that is imported, and there is no warning showing up (correct)
    • I have another BeanRegistrar implementation that is NOT imported anywhere and there is a warning showing up (correct)
    • All other classes in that project also show up a warning about not being registered, even through they don't implement BeanRegistrar at all. Creating a plain simple new Java class immediately shows the warning - wich is definitely not correct.
  6. added 3 commits that reference this issue on Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

for: eclipsefor: vscodetheme: validationtype: enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions