2015-11-08 54 views
9

我剛剛從14.1升級到IntelliJ 15.0(我很着急,enter image description here忘記保存以前的插件狀態爲14.1),我試圖配置一般的運行/使用Gradle在Intellij中使用Spring Boot調試配置設置。在配置選項卡中,我添加了1)Main類,2)JRE和3)IntelliJ中模塊的類路徑。我使用Spring Boot作爲選定的配置。然而,當選擇來看,我得到這個錯誤:這裏java.lang.NoClassDefFoundError:javax/servlet/ServletContext

2015-11-07 22:00:21.457 ERROR 10632 --- [main] 
o.s.boot.SpringApplication : Application startup failed 
java.lang.NoClassDefFoundError: javax/servlet/ServletContext  
at java.lang.Class.getDeclaredMethods0(Native Method) 
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 
at java.lang.Class.getDeclaredMethods(Class.java:1975) 
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:140) 
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:289) 
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) 
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196) 
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165) 
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) 
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) 
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) 
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) 
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) 
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) 
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 
at org.awana.mozo.club.Application.main(Application.java:37) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext 
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
2015-11-07 22:00:21.457 INFO 10632 --- [   main] s.c.a.AnnotationConfigApplicationContext : Closing org.spring[email protected]3788f3 : startup date [Sat Nov 07 22:00:21 CST 2015]; root of context hierarchy 
2015-11-07 22:00:21.458 WARN 10632 --- [   main] s.c.a.AnnotationConfigApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent 
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.spring[email protected]3788f3: startup date [Sat Nov 07 22:00:21 CST 2015]; root of context hierarchy 
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344) 
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) 
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:869) 
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:342) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 
at org.awana.mozo.club.Application.main(Application.java:37) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 
2015-11-07 22:00:21.459 WARN 10632 --- [   main] s.c.a.AnnotationConfigApplicationContext : Exception thrown from LifecycleProcessor on context close 
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.spring[email protected]3788f3: startup date [Sat Nov 07 22:00:21 CST 2015]; root of context hierarchy 
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357) 
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:877) 
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:342) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 
at org.awana.mozo.club.Application.main(Application.java:37) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet /ServletContext 
at java.lang.Class.getDeclaredMethods0(Native Method) 
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 
at java.lang.Class.getDeclaredMethods(Class.java:1975) 
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(Sta ndardAnnotationMetadata.java:140) 
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigu rationClass(ConfigurationClassParser.java:289) 
at org.springframework.context.annotation.ConfigurationClassParser.processConfigura tionClass(ConfigurationClassParser.java:229) 
at org.springframework.context.annotation.ConfigurationClassParser.parse(Configurat ionClassParser.java:196) 
at org.springframework.context.annotation.ConfigurationClassParser.parse(Configurat ionClassParser.java:165) 
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processCo nfigBeanDefinitions(ConfigurationClassPostProcessor.java:306)    
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProce ssBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) 
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBean DefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) 
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBean FactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) 
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactory PostProcessors(AbstractApplicationContext.java:606) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) 
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 
at org.awana.mozo.club.Application.main(Application.java:37) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext 
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
Process finished with exit code 1 

回答

1

OK是我必須做的來解決這個具體問題:的IntelliJ需要有一個定義搖籃任務調試/運行配置中調用bootRun。這使我現在可以在IntelliJ中運行後端代碼或調試後端代碼更新。 2)接下來,我必須重構我的IntelliJ目錄,因爲IntelliJ 15已經安裝了父和子JRE文件夾,這是不正確的,因此IntelliJ顯示和異常聲明它找不到a)java.exec和b)jvm。它的JRE/Lib子目錄下的cfg文件。一旦我解決了這兩個問題,構建和調試似乎都適用於Java Spring後端。我跟隨了IntelliJ關於奇怪的JRE安裝。

+0

做你養你票'youtrack'(JetBrains的門票網站) - 如果是這樣,請你能在這裏引用它。 – arcseldon

+0

我相信我已經做到了,但我仍然在尋找機票。 – user1548875

+0

好的,np - 知道經驗......謝謝你的回覆。 – arcseldon

14

有同樣的問題。似乎特定於嘗試通過IntelliJ 15.x 運行配置來運行Spring Boot Web應用程序。由於我使用的是maven,我改爲創建了maven運行配置,將command line action指定爲spring-boot:run - 這適用於運行和調試模式。附上截圖。

enter image description here