Spring Run Configurations
Hi, I want to create a new Spring run configuration programmatically.
I managed to do it with Java configurations, but have few issues with Spring:
1. First, without adding Spring jars, I don't have Spring configuration objects. Is there a better way to add the jars other than doing it manually (in my company everyone is using the Ultimate version)?
2. After I added it, I get this error: class com.intellij.spring.boot.run.SpringBootApplicationConfigurationType cannot be cast to class com.intellij.spring.boot.run.SpringBootApplicationConfigurationType (com.intellij.spring.boot.run.SpringBootApplicationConfigurationType is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @6eeea326; com.intellij.spring.boot.run.SpringBootApplicationConfigurationType is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @4b3b0f42)
3. Is there a way to add the configuration as XML programmatically?
My code:
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
RunManager runManager = RunManager.getInstance(e.getProject());
RunnerAndConfigurationSettings runnerAndConfigurationSettings = runManager.createConfiguration("", new SpringBootApplicationConfigurationType().getDefaultConfigurationFactory());
final SpringBootApplicationRunConfigurationBase applicationConfiguration = (SpringBootApplicationRunConfigurationBase) runnerAndConfigurationSettings.getConfiguration();
applicationConfiguration.setModule(...);
applicationConfiguration.setSpringBootMainClass("...");
runManager.addConfiguration(runnerAndConfigurationSettings);
}
Thanks
Please sign in to leave a comment.
1. no
2. did you specify "com.intellij.spring.boot" in <depends> of your plugin.xml? did you add all JARs from Spring Boot plugin?
3. I don't understand this question
I did specify now, still get the same error.
Please double-check you added Spring/Spring Boot JARs to SDK, not to your plugin classpath http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
re 3, see com.intellij.execution.RunnerAndConfigurationSettings#setShared to share the run configuration
I should have added SpringBoot to build.gradle:
I'm not sure how and if it will work when I will publish it solves the error.