news 2026/9/10 9:24:41

【报错】BeanCreationException: Error creating bean with name ‘xxController‘: Injection of autowired ....

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
【报错】BeanCreationException: Error creating bean with name ‘xxController‘: Injection of autowired ....

一、报错内容

org.springframework.beans.factory.BeanCreationException: Error creating bean with name'authController':Injection of autowired dependencies failed;nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder'auth.username'invalue"${auth.username}"at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]at com.xafande.atc.aftnsocket.AftnsocketApplication.main(AftnsocketApplication.java:12)~[classes/:na]Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder'auth.username'invalue"${auth.username}"at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178)~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:236)~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175)~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:909)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1228)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]...17common frames omitted Disconnected from the target VM, address:'127.0.0.1:51727', transport:'socket'Process finished withexitcode1

二、思路分析


报错的是两个@Value这里,很明显,咱们遇到的是一个spring管理注入失败的问题。

三、 解决报错


试了一下 可以把中间替换成:

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/10 9:23:20

浪潮服务器功耗计算器

浪潮M5服务器功耗计算器:功耗计算器https://www.inspur.com/eportal/ui?pageId2507914浪潮功耗计算器工具https://www.inspur.com/lcjtww/ghjsq11/index.htmlhttps://www.inspur.com/lcjtww/ghjsq11/index.html计算产品能耗计算器 华为:能耗计算器Huaw…

作者头像 李华
网站建设 2026/9/10 9:21:14

空输入场景下的技术内容生成合规边界

我无法根据当前输入生成符合要求的博文。原因如下:项目标题“marketingskills”仅为一个宽泛的英文词汇,未体现具体项目、技术实现、实操场景或问题导向;项目正文为空;关键词为空;摘要描述为空;所谓“相关热…

作者头像 李华
网站建设 2026/9/10 9:21:05

camofox-browser:基于Firefox的浏览器指纹伪装实战

看到 camofox-browser 这个名字,我的第一反应是:项目作者挺会起名字的。camo 是 camouflage(伪装)的缩写,fox 指代 Firefox 内核,合起来的意思很直白——这是一个主打浏览器指纹伪装、让网站难以追踪和识别…

作者头像 李华
网站建设 2026/9/10 9:17:43

大模型的元认知错觉:过度自信、幻觉与校准策略

最近我一直在帮团队调试一个农业问答系统,底层的模型在处理“土壤pH值偏酸时该用哪种肥料”这类问题时,给出了一套非常漂亮的方案,用量配比、施用周期都写得很具体。可拿给农业专家复核,对方看了一眼就摇头:这个配方在…

作者头像 李华
网站建设 2026/9/10 9:16:39

Ubuntu 20.04无人机开发环境构建指南:PX4+ROS+Gazebo全链路工程实践

1. 项目概述:为什么在 Ubuntu 20.04 上构建无人机软件开发环境不是“选修课”,而是硬性入场券你手头有一块 Pixhawk 4 飞控,刚买了树莓派 4B 准备做机载计算机,或者正打算用 NVIDIA Jetson Nano 跑视觉算法——但你的主力开发机还…

作者头像 李华