报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-06-20 17:41:32.653 ERROR 9192 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of constructor in com.linksoul.zfau.aiops.service.MsgPushServiceImpl required a bean of type 'java.lang.String' that could not be found.
Action:
Consider defining a bean of type 'java.lang.String' in your configuration.
@Service
@AllArgsConstructor
public class MsgPushServiceImpl {
@Value("${msg.appId}")
private String APPID;
...
}
原因:
经过排查后,因为springioc容器加载bean默认使用无参构造进行初始化,该实现层使用了@AllArgsConstructor注解,而@Value注入一个属性值,其并不会存在于Spring容器,所以报错。文章来源地址https://www.toymoban.com/news/detail-752596.html
解决方案:
将@RequiredArgsConstructor注解替换@AllArgsConstructor注解即可。
@Service
@RequiredArgsConstructor
public class MsgPushServiceImpl {
@Value("${msg.appId}")
private String APPID;
...
}
文章来源:https://www.toymoban.com/news/detail-752596.html
到了这里,关于解决‘java.lang.String’报错:Consider defining a bean of type ‘java.lang.String‘ in your configuration的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!