HelloWorldControllerを書き、Run As > spring boot Appで実行したのですが、localhost:8080にアクセスしても「このサイトにアクセスできません」と表示されます。
「Cannot load configuration class: jp.hello.HelloApplication」とあるようにHelloApplicationクラスに不備があるかもしれませんが、特にいじっておらず、デフォルトのままです。
なにかあればヒントをいただけないでしょうか。
version
Spring tool suite4
java11
mysql8
spring boot 2.0.6.RELEAS
java
1// HelloApplication.java 2package jp.hello; 3 4import org.springframework.boot.SpringApplication; 5import org.springframework.boot.autoconfigure.SpringBootApplication; 6 7@SpringBootApplication 8public class HelloApplication { 9 10 public static void main(String[] args) { 11 SpringApplication.run(HelloApplication.class, args); 12 } 13}
java
1// HelloWorldController.java 2package jp.hello; 3 4import org.springframework.web.bind.annotation.RequestMapping; 5import org.springframework.web.bind.annotation.RestController; 6 7@RestController 8public class HelloWorldController { 9 10 @RequestMapping("/") 11 public String helloworld() { 12 return "Hello World!"; 13 } 14}
error文
java
12018-10-23 18:20:19.480 ERROR 1113 --- [ main] o.s.boot.SpringApplication : Application run failed 2 3java.lang.IllegalStateException: Cannot load configuration class: jp.hello.HelloApplication 4 at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:414) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 5 at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:254) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 6 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:282) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 7 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:126) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 8 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:692) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 9 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 10 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 11 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 12 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 13 at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 14 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 15 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] 16 at jp.hello.HelloApplication.main(HelloApplication.java:10) ~[classes/:na] 17Caused by: java.lang.ExceptionInInitializerError: null 18 at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:122) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 19 at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 20 at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] 21 ... 12 common frames omitted 22Caused 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 @27bc8519 23 at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 24 at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 25 at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 26 at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 27 at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 28 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na] 29 at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 30 at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 31 at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 32 at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 33 at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 34 at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:174) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 35 at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:153) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 36 at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 37 ... 15 common frames omitted 38Caused 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 @27bc8519 39 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340) ~[na:na] 40 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280) ~[na:na] 41 at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198) ~[na:na] 42 at java.base/java.lang.reflect.Method.setAccessible(Method.java:192) ~[na:na] 43 at org.springframework.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 44 at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na] 45 at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:52) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 46 at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 47 at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 48 at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] 49 ... 27 common frames omitted
参考サイト
【Spring Boot 入門】初めてのHello World!
https://xn--hckj0bf8p.com/spring-boot-getting-started-hello-world/
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。