How can I deal with unmapped spring configuration files in IntelliJ - spring

When dealing with this problem, I already understand that I need to do File -> Project Structure -> modules -> + -> and select spring. However what I don't understand is in what part of modules I need to have selected before I click +, and which spring option to choose. I don't see a singular Spring option, but instead Spring batch, Spring DM configuration, Spring MVC, and more. Should I choose one of these options? Or do I need to configure something so that I only see the Spring option.

Related

Is there a way to generate application properties when creating a Spring Boot project?

I'm planning to run our own Spring Initializr instance. Is there a way to have a set of application properties get written (to application.yml) when a certain option is chosen, ideally in a separate section for each of a set of predefined profiles? I've looked into customising the project-generation process in Initializr and at creating a custom starter. I've come across auto-configuration for starters, but that seems to be about what configuration to default to when this has not been provided by properties, whereas I am after generating the properties. I've also come across an example of a custom Spring Initializr instance generating files, but I need it to modify application.yml without clobbering any other modifications that may have been made to it.
Spring Initializr (the library behind start.spring.io) does not have yaml support and does not allow you to write such file automatically when the project is generated.
It's easy enough for you to add that feature though. The way it works is through a model that contributors would tune + a writer that transform the model into the target output. An analogy of this would be MavenBuild and MavenBuildWriter that generates Maven's pom.xml.
Auto-configuration is indeed completely unrelated to code/configuration generation so no need to look there.

What are the consequences of checking "Disable Auto Config Detection" in the Eclipse Spring preferences?

I mean the Eclipse preference under Window|Preferences|Spring|Beans Support
"Disable Auto Config Detection".
When this option is not checked, I notice a delay when saving Java files:
Building Workspace...
Loading ...ServerApplication
or
Loading ...DaoConfig
These messages are for Spring Boot main application classes (ServerApplication) or Spring configuration classes with #ComponentScan (DaoConfig) which are located in the workspace.
This can take a few seconds, which is a bit annoying.
When I check the above preference option, I don't notice the delay for loading these classes (at least for the Spring Boot main classes).
What are the consequences of disabling Auto Config Detection, e.g. what does this option really do, what functionality do I loose? Any pointers to documentation?
Can I speed up the save process without having to disable Auto Config Detection?
In STS3, the IDE creates an internal model of your Spring application, so that it can display a nice overview of your Spring elements in the Spring Explorer view, provide content-assist in Spring XML config files and more. In order to build up this internal Spring beans model, it needs to know where to start from when building that model. You can define those entry points manually in the properties for each project: Spring -> Beans Support. That preference allows you to define Spring XML config files and/or Spring-annotated configuration classes to be used by the IDE internally to build up that model.
In addition to that there is a mechanism to detect those files (Spring XML config files and Spring Boot application configuration annotations) automatically, so that you don't need to configure them manually. But the result is the same. Those files/classes end up being configured to be used by the IDE to built this internal model.
I guess that the delay that you see comes from building this internal beans model - this is at least what the messages indicate that you mentioned.
So far for the background. You can disable that auto-config mechanism and you don't need to configure those files/classes manually. This will result in the Spring Explorer, for example, not showing anything meaningful for those projects.
As an alternative and in case you are working mostly with Spring Boot projects, I would strongly recommend to switch to the all-new Spring Tools 4 (also available as a ready-to-use Eclipse distribution). It provides a slightly different set of features and is implemented in a different way, so that it doesn't need the expensive internal bean model creation. You should give it a try. And if you are missing something that you love in STS3 that is not yet part of Spring Tools 4, let us know.

"Open Live Beans Graph" is disabled

I have a Spring MVC project inside of Spring Tools Suite that uses Java based Spring configuration and Gradle.
- I've added the Spring Project Nature.
- I'm not using #ComponentScan, I define all beans explicitly.
- I have "Auto detection for annotated Java Spring configuration files" turned on.
Why is "Open Live Beans Graph" disabled (greyed out) in my Project/Spring Tools menu?
Thanks!
The live beans graph is showing the beans that are being created in the running application, so you need to run the app (in your case I guess you run that in tc Server), and open the live beans graph view for that application. You can do that from the tc Server editor, there is a section for live bean graphs being available (and you can enable the feature in general).
If you do not run the app in tc Server, you have to set a property in order to enable this feature in your running application and connect to that application from the live beans graph view manually.
Hope that helps!
Spring MVC may not be enough to get it to work.
https://docs.spring.io/sts/nan/v310/NewAndNoteworthy.html says:
To allow proper communication, servers must be configured to enable
JMX and must also be given the VM argument
'-Dspring.liveBeansView.mbeanDomain' in order for the Spring Framework
to produce the data required to build up the graph.
I think the easiest is to get it to run in Spring Boot.
https://codecentric.github.io/spring-boot-admin/1.4.3/#jmx-bean-management

Unable to get rid of Spring Configuration Check since upgrading to IntelliJ IDEA 13

I keep getting spring configuration checks at project open even though Spring facet has been configured for the specified module.
Spring Configuration Check
Unmapped Spring configuration files found
Please configure/setup Spring facet for modules:
flow (1 file)
Unlike the scenario in this question, I have verified several times that I have added the Spring facet to the "flow" module in Project/Module Properties, but the warning still comes up. Two questions: how to fix and 2) how to turn off this check altogether.
To disable IntelliJ Spring configuration notifications, go to:
Preferences > Notifications > Spring Configuration Check > No popup

Validate Spring XML schemas against XSDs from classpath

Can anyone tell me what the best strategy to validate a spring configuration file against the spring-beans.xsd that is included with the spring-beans.jar. Can I have the schemaLocation in the XML header reference file:/org/springframework/beans/factory/xml/spring-beans-2.0.xsd?
The best way is to use the Spring IDE and it will perform the validation during dev time. Also, spring auto validates all the config files (from the XSD that comes bundled with the jars) while it is loading them.
ok here is the deal.... Eclipse uses plugins like spring IDE or spring STS that have spring bean validators in them.
There is an issue When the new versions of spring components come out the xsds do not appear to be in the eclipse plugins validators ahead of time. So eventually they create bug or enhancement requests in the projects JIRA system and they are put in in a new release/update. You can vote on these bugs to let them know there is demand to get them in faster.
There is also a work around to use in the interim in this old blog post by Craig Walls
http://www.springone2gx.com/blog/craig_walls/2007/08/fixing_spring_modules_xsd_errors_in_eclipse

Resources