当前位置: 首页 > 知识库问答 >
问题:

IntelliJ在运行Spring Boot应用程序时抛出错误,而在从终端运行时不抛出错误?

皇甫雨华
2023-03-14

我想从intelliJ运行我的spring-boot应用程序,而不是使用终端,但它不允许,它只是抛出了一大堆错误,而当我从intelliJ中的终端运行mvn spring-boot:run时,应用程序会按预期启动。

通过intelliJ(右上角的run按钮)运行时:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.5.RELEASE)

2016-06-16 17:41:37.783  INFO 7968 --- [  restartedMain] spring.Application                       : Starting Application on JamesWMAC.local with PID 7968 (/Users/james/IdeaProjects/myProject/target/classes started by james in /Users/james/IdeaProjects/myProject)
2016-06-16 17:41:37.786  INFO 7968 --- [  restartedMain] spring.Application                       : No active profile set, falling back to default profiles: default
2016-06-16 17:41:37.863  INFO 7968 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4a81556: startup date [Thu Jun 16 17:41:37 EST 2016]; root of context hierarchy
2016-06-16 17:41:39.263  INFO 7968 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e89ecf20] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-16 17:41:39.604  INFO 7968 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-06-16 17:41:39.621  INFO 7968 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-06-16 17:41:39.622  INFO 7968 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.33
2016-06-16 17:41:39.697  INFO 7968 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-06-16 17:41:39.697  INFO 7968 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1838 ms
2016-06-16 17:41:39.889  INFO 7968 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-06-16 17:41:39.892  INFO 7968 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-06-16 17:41:39.892  INFO 7968 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-06-16 17:41:39.892  INFO 7968 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-06-16 17:41:39.892  INFO 7968 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-06-16 17:41:40.157  INFO 7968 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-06-16 17:41:40.163  INFO 7968 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2016-06-16 17:41:40.167  WARN 7968 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
2016-06-16 17:41:40.172  INFO 7968 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2016-06-16 17:41:40.182 ERROR 7968 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
    at spring.Application.main(Application.java:47) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_05]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.5.RELEASE.jar:1.3.5.RELEASE]
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_05]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_05]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_05]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_05]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_05]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_05]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_05]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_05]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_05]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_05]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_05]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_05]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:486) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:208) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:188) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319) ~[spring-orm-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    ... 21 common frames omitted

2016-06-16 17:41:40.183  INFO 7968 --- [  restartedMain] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/Users/james/IdeaProjects/myProject/target/classes/]

但当我去跑的时候:

mvn spring-boot:run

在终端中,我的应用程序启动,我可以开始对服务器进行http调用。

共有1个答案

宋健柏
2023-03-14

我知道这不及时=),但我刚刚解决了同样的问题,在我的情况下,它解决了我从IntelliJ更新Maven依赖项。

 类似资料:
  • 我已经完成了Eclipse Maven TestNG,我打算运行Selenium测试用例。 这是我的POM文件: 现在,当我尝试运行Maven测试时,我得到以下错误: 有人能告诉我我错过了什么吗。 提前谢谢。

  • 我使用log4j2,但我的一些依赖项使用log4j。当我从一个可执行jar文件运行应用程序时,我只得到几行日志和以下消息: 但当我在IntelliJ内部运行应用程序时,它会按预期工作,不会产生任何警告和所有日志。 我用maven enforcer来禁止log4j。我还尝试添加依赖项,但将范围设置为“提供”。 我也用一个版本号而不是一个范围来完成上面的工作。当应用程序在IntelliJ中运行时,所有

  • 开始调试时,出现以下错误: 正在启动lib\main。调试模式下ONEPLUS A5000上的dart。。。lib\main。dart:1E/AndroidRuntime(11211):以书面形式命名,pkgName:com。刚出现的包裹azabazar E/AndroidRuntime(11211):致命异常:主E/AndroidRuntime(11211):进程:com。刚出现的包裹阿扎巴扎,

  • 初始化引导层java.lang.Module.FindException时出错:在使用eclipse创建一个新的springboot应用程序并运行它时找不到模块jdk.management.agent。

  • 在运行简单的GWT应用程序时获取错误。当我用ant通过命令行运行时,它工作得很好,但在IntelliJ中导入后,我得到了这个错误。不知道为什么我会得到这个错误:

  • 中的这个简单程序会引发错误。可能的原因是什么?此问题在我安装/重新安装 后出现。此外已安装在我的PC上(视窗10机器)。 错误消息: 文件"C:\Python36\lib\subprocess.py",第336行,check_output**kwargs). stdout 文件"C:\Python36\lib\subprocess.py",第403行,以Popen(*popenargs,**kwa