Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java BeanCreationException,弹簧靴_Java_Maven_Spring Boot_Spring Mvc - Fatal编程技术网

Java BeanCreationException,弹簧靴

Java BeanCreationException,弹簧靴,java,maven,spring-boot,spring-mvc,Java,Maven,Spring Boot,Spring Mvc,我正在建立一个SpringBootMaven多模块项目,其中包括域层、持久层和Web层 我一直在寻找类似的问题,但似乎没有一个是我的情况下,我怀疑这是因为事实上,该项目是在单独的maven模块划分春天找不到bean 尝试了一些可行的解决方案,但似乎无法解决问题 主要 RestController 坚持不懈 似乎主要的问题是缺乏电影定位的实施 Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.rep

我正在建立一个SpringBootMaven多模块项目,其中包括域层、持久层和Web层

我一直在寻找类似的问题,但似乎没有一个是我的情况下,我怀疑这是因为事实上,该项目是在单独的maven模块划分春天找不到bean

尝试了一些可行的解决方案,但似乎无法解决问题

主要 RestController 坚持不懈
似乎主要的问题是缺乏电影定位的实施

Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.repository.MovieRepository
您没有提供pom.xml,因此无法验证所有依赖项是否正确,但我怀疑您可能缺少

有关此注释和中的详细信息

例如:

@Configuration
@EnableJpaRepositories("com.acme.repositories")
class ApplicationConfiguration {

  @Bean
  EntityManagerFactory entityManagerFactory() {
    // …
  }
}

我通过在主类中添加组件扫描解决了这个问题

@SpringBootApplication(scanBasePackages = { "com" })
@EntityScan(basePackages = { "com" })
public class SpringBootAplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringBootAplication.class, args);
    }

}


这样,spring在所有maven模块中都有一个通用的基本包,它可以扫描组件。

您需要扫描这些包。通过添加@componentScan注释

您的
pom.xml
?你能把它的相关部分添加到你的问题中吗?
@Repository
public interface MovieRepository extends JpaRepository<Movie, Long> {

}

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

2019-05-18 21:42:40.598  INFO 1696 --- [           main] c.i.movie.web.SpringBootAplication       : Starting SpringBootAplication on DESKTOP-Q7NDFBT with PID 1696 (C:\Desarollo\wks\Parent\Web\target\classes started by Usuario in C:\Desarollo\wks\Parent\Web)
2019-05-18 21:42:40.598  INFO 1696 --- [           main] c.i.movie.web.SpringBootAplication       : No active profile set, falling back to default profiles: default
2019-05-18 21:42:43.114  INFO 1696 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2019-05-18 21:42:43.134  INFO 1696 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-05-18 21:42:43.134  INFO 1696 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-05-18 21:42:43.165  INFO 1696 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_202\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_202/bin/server;C:/Program Files/Java/jre1.8.0_202/bin;C:/Program Files/Java/jre1.8.0_202/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Calibre2\;C:\Program Files\Git\cmd;C:\Users\Usuario\AppData\Local\Microsoft\WindowsApps;;C:\Microsoft VS Code\bin;C:\eclipse\eclipse-jee-2019-03-R-win32-x86_64\eclipse;;.]
2019-05-18 21:42:43.745  INFO 1696 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-05-18 21:42:43.745  INFO 1696 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3100 ms
2019-05-18 21:42:44.276  WARN 1696 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'movieService' defined in file [C:\Desarollo\wks\Parent\Domain\target\classes\com\imricki\movie\domain\impl\MovieServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@764c12b6]
2019-05-18 21:42:44.286  INFO 1696 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-05-18 21:42:44.348  INFO 1696 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-18 21:42:44.442 ERROR 1696 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'movieService' defined in file [C:\Desarollo\wks\Parent\Domain\target\classes\com\imricki\movie\domain\impl\MovieServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@764c12b6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:570) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at com.imricki.movie.web.SpringBootAplication.main(SpringBootAplication.java:11) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@764c12b6]
    at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:785) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:717) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:365) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:350) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:298) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1061) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:567) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    ... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Lcom/imricki/movie/persistence/repository/MovieRepository;
    at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_202]
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_202]
    at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_202]
    at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:780) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.repository.MovieRepository
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_202]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_202]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_202]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_202]
    ... 25 common frames omitted


Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.repository.MovieRepository
@Configuration
@EnableJpaRepositories("com.acme.repositories")
class ApplicationConfiguration {

  @Bean
  EntityManagerFactory entityManagerFactory() {
    // …
  }
}
@SpringBootApplication(scanBasePackages = { "com" })
@EntityScan(basePackages = { "com" })
public class SpringBootAplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringBootAplication.class, args);
    }

}