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

无法在Springboot上运行java代码示例

闻人志
2023-03-14

我无法在Springboot java上运行代码示例。有人有解决方案吗?我能做什么我不知道我刚刚开始。。。

09:57:28.372[main]调试组织。springframework。靴子开发工具。设置。DevToolsSettings-包括重启模式:[]09:57:28.374[main]调试组织。springframework。靴子开发工具。设置。devtools设置-排除重启模式:[/spring boot starter-[\w-]/,/spring boot/target/classes/,/spring boot starter/target/classes/,/spring boot devtools/target/classes/,/spring boot actuator/target/classes/,/spring boot autoconfigure/target/classes/]09:57:28.374[main]调试组织。springframework。靴子开发工具。重新启动。ChangeableUrls-匹配重新加载的URL:[文件:/D:/Java/workspace/petclinic/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v2.0.0.RELEASE)[0;39m

[2m2021-10-08 09:57:28.541[0;39m [32m INFO[0;39m [35m564[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36mc.j.petclinic.PetClinicApplication      [0;39m [2m:[0;39m Starting PetClinicApplication on DESKTOP-BCNBHLN with PID 564 (D:\Java\workspace\petclinic\target\classes started by PcOne in D:\Java\workspace\petclinic)
[2m2021-10-08 09:57:28.542[0;39m [32m INFO[0;39m [35m564[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36mc.j.petclinic.PetClinicApplication      [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-10-08 09:57:28.575[0;39m [32m INFO[0;39m [35m564[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@43586274: startup date [Fri Oct 08 09:57:28 TRT 2021]; root of context hierarchy
[2m2021-10-08 09:57:29.088[0;39m [31mERROR[0;39m [35m564[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

java.lang.IllegalStateException: Cannot load configuration class: com.javaegitimleri.petclinic.PetClinicApplication
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:416) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:254) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:128) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at com.javaegitimleri.petclinic.PetClinicApplication.main(PetClinicApplication.java:11) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.0.0.RELEASE.jar:2.0.0.RELEASE]
Caused by: java.lang.ExceptionInInitializerError: null
    at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:122) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:405) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 17 common frames omitted
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @55a147cc
    at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:174) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:153) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 20 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @55a147cc
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) ~[na:na]
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) ~[na:na]
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) ~[na:na]
    at org.springframework.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) ~[na:na]
    at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:52) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 32 common frames omitted

[2m2021-10-08 09:57:29.089[0;39m [32m INFO[0;39m [35m564[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@43586274: startup date [Fri Oct 08 09:57:28 TRT 2021]; root of context hierarchy

共有1个答案

熊哲圣
2023-03-14

解决方案图片

我找到了解决办法。当我将Springboot版本更改为2.1.1时,它就完成了!

 类似资料:
  • 我尝试在eclipse中运行下面的代码,发布在这里。 但它并没有被执行。它抛出以下错误: 注意:我还添加了来自lib/extjmetr安装文件的外部罐 代码:

  • 我是owlapi的新手,我正尝试在debian上编写一个java代码示例,以加载我已经使用Protégé构建的本体。我正在使用“owlapi-osgiDistribution-4.0.2.jar”,但总是得到这个错误: 我试图使用maven进行依赖,但徒劳。谁能告诉我如何解决这个问题,谢谢。

  • 我无法在VS代码上运行Tomcat服务器。 错误信息如下 但是,我的tomcat文件夹放在D驱动器上,与源代码文件夹相同。我不知道它为什么要搜索“C:\Program”文件夹。如果你能帮忙,我真的很感激。非常感谢。 jdk1.8 Windows10 VS code1.47.2 Tomcat9.0.37 在此处输入图像描述

  • 我刚刚下载了IDE,我想用它编辑我的第一个Java文件,我对创建整个项目不感兴趣,只是编辑单个文件。 因此,我使用Intellij IDEA从桌面上打开了该文件,因为我将其设置为打开。java文件的默认程序。 我写了一些代码,主运行和调试按钮是灰色的!我不能运行我的代码! 编辑:我也无法运行我的文件,无论它是否在一个项目中。

  • 问题内容: codepad.org允许您在线运行C,C ++,D等代码,但不能运行Java …我可以使用Java的网站吗? 问题答案: 还有http://ideone.com/(支持多种语言)