首页 > 解决方案 > Spring/Springboot Autowire 场景结果

问题描述

以下场景在编译时和运行时对于 MyProjectService 的行为将是什么:

Beans XML 配置:

<bean id="myProjectService" class="com.someco.MyProjectService" />

Java 代码:

@Component
public class MyClient implements IClient {

    @Autowired(required = false)
    private MyProjectService MyProject;
}

请注意 XML 中的 bean id 和客户端类中的变量名。

无论如何,当引用用于调用类上的某些方法时,这会在运行时抛出NoClassDefFoundError吗?MyProjectMyProjectService

标签: javaspringspring-bootautowirednoclassdeffounderror

解决方案


推荐阅读