V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
adli007
V2EX  ›  程序员

spring boot 启动报错, Error creating bean with name 'restTemplateBuilder'。在网上搜了很久也没找到相关的信息,大家帮忙看看是什么问题,

  •  1
     
  •   adli007 · 2018-06-05 17:37:59 +08:00 · 15308 次点击
    这是一个创建于 2367 天前的主题,其中的信息可能已经有所发展或是发生改变。

    :: Spring Boot :: (v2.0.2.RELEASE)

    2018-06-05 17:29:50.692 INFO 6608 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on LIDA with PID 6608 (E:\Downloads\demo\target\classes started by Administrator in E:\Downloads\demo) 2018-06-05 17:29:50.698 INFO 6608 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-06-05 17:29:50.778 INFO 6608 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6b1274d2: startup date [Tue Jun 05 17:29:50 CST 2018]; root of context hierarchy 2018-06-05 17:29:52.002 WARN 6608 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplateBuilder' defined in class path resource [org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.web.client.RestTemplateBuilder] from ClassLoader [sun.misc.Launcher$AppClassLoader@73d16e93] 2018-06-05 17:29:52.004 INFO 6608 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown 2018-06-05 17:29:52.015 INFO 6608 --- [ main] ConditionEvaluationReportLoggingListener :

    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-06-05 17:29:52.025 ERROR 6608 --- [ main] o.s.boot.SpringApplication : Application run failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplateBuilder' defined in class path resource [org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.web.client.RestTemplateBuilder] from ClassLoader [sun.misc.Launcher$AppClassLoader@73d16e93] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:15) [classes/:na] Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.web.client.RestTemplateBuilder] from ClassLoader [sun.misc.Launcher$AppClassLoader@73d16e93] at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:758) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:690) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:355) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:339) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:298) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1020) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 14 common frames omitted Caused by: java.lang.NoClassDefFoundError: Lorg/springframework/http/client/support/BasicAuthorizationInterceptor; at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_121] at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_121] at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_121] at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:753) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 20 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.http.client.support.BasicAuthorizationInterceptor at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121] ... 24 common frames omitted

    13 条回复    2018-06-13 23:33:23 +08:00
    wenzhoou
        1
    wenzhoou  
       2018-06-05 18:14:05 +08:00 via Android
    这么多人都是 TL;DS
    night98
        2
    night98  
       2018-06-05 18:17:07 +08:00
    重新导包试一下,信息太少无法排查。
    adli007
        3
    adli007  
    OP
       2018-06-05 19:11:04 +08:00
    @night98 导了,也显示导成功了,还是没用
    night98
        4
    night98  
       2018-06-05 19:11:57 +08:00
    @adli007 #3 把.m2 中有关 springboot 的文件夹都删了重新下一下试试
    adli007
        5
    adli007  
    OP
       2018-06-05 19:47:36 +08:00
    @night98 还是不行
    wenzhoou
        6
    wenzhoou  
       2018-06-05 21:25:43 +08:00 via Android
    你只要把上面的 stack trace 重新排版一下就有不少人帮你。这个不排版拿手机真没法看啊。
    mringg
        7
    mringg  
       2018-06-05 22:07:04 +08:00 via iPhone
    ClassNotFoundException: org.springframework.http.client.support.BasicAuthorizationInterceptor
    如果异常信息全,那么是这触发的
    adli007
        8
    adli007  
    OP
       2018-06-05 23:06:17 +08:00
    @wenzhoou 现在改不了,追加又超字了...当时没考虑好
    adli007
        9
    adli007  
    OP
       2018-06-05 23:06:55 +08:00
    @mringg 不知道这是什么错,我还是重新搭建一个吧
    xuuuu
        10
    xuuuu  
       2018-06-06 08:46:04 +08:00 via Android
    自己创建个 bean 把这个对象 new 出来返回
    neuliuxi
        11
    neuliuxi  
       2018-06-06 11:50:32 +08:00
    : No active profile set, falling back to default profiles: 有可能是这个问题吗
    maxiaofeng
        12
    maxiaofeng  
       2018-06-06 18:35:34 +08:00
    看到楼上的这句,,‘: No active profile set, falling back to default profiles:’
    我推测是:没有加载到 远程 git 配置中心的配置文件。
    jack80342
        13
    jack80342  
       2018-06-13 23:33:23 +08:00
    这几天翻译了最新的 Spring Boot 2.0 的英文文档,欢迎 Fork,https://www.gitbook.com/book/jack80342/spring-boot/details
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1062 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:49 · PVG 03:49 · LAX 11:49 · JFK 14:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.