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

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

Closed
martinlippert opened this issue Mar 4, 2025 · 2 comments
Assignees
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: validation type: enhancement

Comments

@martinlippert
Copy link
Member

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 {
...
@BoykoAlex
Copy link
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

@martinlippert
Copy link
Member Author

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.

martinlippert added a commit that referenced this issue Mar 20, 2025
martinlippert added a commit that referenced this issue Mar 20, 2025
…g of specific files once the index is complete
martinlippert added a commit that referenced this issue Mar 24, 2025
@martinlippert martinlippert self-assigned this Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: validation type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants