To build a microservice architecture using springcloud, the spring boot starter web dependency is referenced in the parent, but the subproject cannot be started. The error is as follows:
Build springcloud project encountered problems
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.autoconfigure.BackgroundPreinitializer
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:450)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:429)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:270)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.hm.SchoolApplication.main(SchoolApplication.java:17)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector
at org.springframework.boot.autoconfigure.BackgroundPreinitializer.<clinit>(BackgroundPreinitializer.java:71)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:446)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.NativeDetector
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 14 more
Solution: it is not enough to rely only on spring boot starter web in the parent project. You should add
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.1.0.RELEASE</version>
</parent>
Just start again.
Read More:
- [Solved] java.lang.IllegalAccessError: class org.springframework.data.redis.core.$ Proxy237 cannot access its superinterface org.springframework.data.redis.core.RedisConnectionUtils$RedisConnectionProxy
- [Solved] SSM startup error: ClassNotFoundException: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- [Integrate the mobile MAS SMS service] SDK start error: NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtil
- [Solved] Maven Project Error: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Defining a bean of type ‘org.springframework.data.redis.core.RedisTemplate‘ in your configuration.
- [Solved] Consider defining a bean of type ‘org.springframework.data.redis.core.RedisTemplate‘ in your configu
- [Solved] org.springframework.context.ApplicationContextException: Failed to start bean ‘org.springframework.a
- [Solved] Spring Boot Error: org.springframework.jdbc.datasource.embedded.EmbeddedData
- [Solved] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org
- [Siolved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘webMvcObject
- [Solved] ERROR org.springframework.boot.SpringApplication – Application run failed org.yaml.snakeyaml.scanner
- [Solved] Java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
- [Solved] Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderA
- [Solved] Failed to introspect Class [org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfigura
- [Solved] org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class
- Eureka Build Error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name
- [Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxx‘
- [Solved] SpringBoot Startup Error: org.springframework.beans.factory.UnsatisfiedDependencyException Error creating
- [Solved] Error creating bean with name ‘org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0‘:
- [Solved] org.springframework.beans.factory.UnsatisfiedDependencyException