Spring构造方法调用父类super无法依赖注入
@Service("airportService")
public class AirportServiceImpl extends BaseServiceImpl
public AirportServiceImpl(Class domainClass, EntityManager em) {
super(domainClass, em);
}
}
Invalid bean definition with name 'airportService' defined in
试过构造方法@autowird方法不起作用,构造方法第一行this.x=x。不可行,因为super必须在第一行
@PersistenceContext
private EntityManager entityManager;
将上述bean通过构造super传入进去
EntityManager 是不是一个超类
spring在实例化bean的时候,发现有构造参数的这时会去找相关的依赖对参数进行注入,如果没有就会报错,无法实例化.
解决:
直接在父类中Autowired
名称重复了,换个名字就好了