Spring 启动失败 Java 14

Spring boot is failed to start with Java 14

我试图在 spring 引导中构建示例 java 14 程序,它构建成功但部署失败。我正在使用 H2 数据库来存储详细信息,实体 bean 不是从不同的 java 模块加载的。

请在此处查找代码库https://github.com/rjvharidas/spring-boot-java14-module

错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'movieController' defined in URL [jar:file:/C:/Users/Dell/My%20Workspace/spring-boot-java14-module/api/target/api-
1.0-SNAPSHOT-exec.jar!/BOOT-INF/classes!/com/rjv/bootcamp/javamodules/api/controller/MovieController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframe
work.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'movieService' defined in URL [jar:file:/C:/Users/Dell/My%20Workspace/spring-boot-java14-module/api/target/api-1.0-SNAPSHOT-exec.
jar!/BOOT-INF/lib/service-1.0-SNAPSHOT.jar!/com/rjv/bootcamp/javamodules/service/service/MovieService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springfram
ework.beans.factory.BeanCreationException: Error creating bean with name 'movieRepository' defined in com.rjv.bootcamp.javamodules.service.repository.MovieRepository defined in @EnableJpaRepositories declared o
n ServiceConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.rjv.bootcamp.javamodules.domain.Movie
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:323) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]

Not a managed type 当实体 class 不在 @EntityScan

下的包中时抛出异常

正如我在您的代码中看到的那样,您已经导入了 ServiceConfiguration,它具有

@EntityScan("com.rjv.bootcamp.javamodules.domain.*")

问题是指定的包格式错误,以 .* 结尾。 可能,您应该将其替换为

@EntityScan("com.rjv.bootcamp.javamodules.domain")