-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
IDE plugin support - information about beans #43208
Comments
Thanks for the suggestion.
I'm not aware of a shared framework for building IDE plugins that allows a plugin implementation to be independent of the IDE implementation. Can you please expand on this? Given that major IDEs such as IntelliJ IDEA already have support for introspecting an application's beans and Spring Boot already has the |
Yes, but it requires running the application. But this is not always possible. I worked on large projects where there was no possibility to run the application locally and development was carried out through tests. (This often requires a local environment - DB and etc.) For example IDEA has also problem with DI context recognized:
If Spring Boot had a build tool plugin (Maven/Gradle) for getting information about beans (without run application) it would greatly simplify the creation of IDE plugins, namely support for DI. Such a build tool task is a platform-independent solution for get context beans and can be used to create a spring-boot support plugin for any IDE (IDEA or VS-CODE) |
Another case too is beans registered through IntelliJ IDEA currently shows a red squiggly because it can't locate a formal |
I think that the premise here is flawed. I agree with Andy, this seems like a rather niche feature for a market that doesn't really exist for now on our side. We're already in touch with IDE vendors and this never came up. |
It would be nice to get all the information about beans (bean definition) in a native way, without starting the application and creating bean instances (start application may have many side effects: DB modification, execute post-construct logic and etc). This can be very useful for creating plugins for IDE independent of IDE implementation.
Maybe there is already something for this?
Maybe it is worth adding some task to Spring Boot Plugins (Maven/Gradle) that like the Maven task 'mvn dependency:tree' , would print out information about beans without starting the application? Then we could just run a build system plugin task, for example for Maven: "mvn org.springframework.boot:spring-boot-maven-plugin:3.2.0:print-bean-definition" , and output information about the beans in some format to the console or file.
I made some prototype - https://github.com/grisha9/spring-bean-printer
The module bean-printer contain logic to print all the bean definition information to the console after the phase "spring.context.beans.post-process". I have custom ApplicationStartup implementation that throw exception after it phase. And custom SpringApplicationRunListener that print all bean info from ConfigurableApplicationContext in failed method.
Also in this module I rewrote the method for launching the spring boot application as shown below. I pass SpringBootApplication class name as env parameter - "org.example.spring.appClassName" and I use my own implementation for ApplicationStartup and SpringApplicationRunListener. And packed it into a jar file - bean-printer.jar
The module project-sample contains simple project for test usages. In this module I added spring-boot-maven-plugin this next configuration
Configuration contains additional classpath element with bean-printer.jar and main class for run it - org.example.bean.printer.BeanDefinitionPrinter and env variable to real application class name.
As result it print bean definition information in console (mvn org.springframework.boot:spring-boot-maven-plugin:3.2.0:run):
Maybe it's worth creating a separate task for build systems for this?
The text was updated successfully, but these errors were encountered: