admin管理员组

文章数量:1531335

 报错信息:

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容器,所以报错。

解决方案:

     将@RequiredArgsConstructor注解替换@AllArgsConstructor注解即可。

@Service
@RequiredArgsConstructor
public class MsgPushServiceImpl {
    @Value("${msg.appId}")
    private String APPID;
...
}

本文标签: 报错StringlangJavaconfiguration