@Component
public class AutowiredObjectFactory
extends org.apache.ibatis.reflection.factory.DefaultObjectFactory
implements org.springframework.context.ApplicationContextAware
这样,HasMany/HasOne 在 infrastructure 的实现类就可以自动注入其他对象,例如DAO
需要配置mybatis-config.xml
<objectFactory type="io.github.dddplus.mybatis.AutowireObjectFactory" />
构造器和说明 |
---|
AutowiredObjectFactory() |
限定符和类型 | 方法和说明 |
---|---|
<T> T |
create(Class<T> type) |
<T> T |
create(Class<T> type,
List<Class<?>> constructorArgTypes,
List<Object> constructorArgs) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
在接口中 org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public <T> T create(Class<T> type)
create
在接口中 org.apache.ibatis.reflection.factory.ObjectFactory
create
在类中 org.apache.ibatis.reflection.factory.DefaultObjectFactory
Copyright © 2020–2023. All rights reserved.