我正在尝试在应用程序启动时将一些数据加载到我的数据库中。我为此目的定义了一个bean
应用程序上下文.xml
<bean class="com.project.loader.DataLoader"
id="DataLoader"
depends-on="entityManagerFactory"
scope="singleton"/>
班级:
@RooJavaBean
@RooConfigurable
public class DataLoader implements InitializingBean
它正在执行,但是在调用第一个 persist() 方法时,Spring 向我抛出以下错误:
Caused by: java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
at com.project.lib.model.extensions.i18n.Locale_Roo_Jpa_ActiveRecord.entityManager_aroundBody0(Locale_Roo_Jpa_ActiveRecord.aj:19)
at com.project.lib.model.extensions.i18n.Locale_Roo_Jpa_ActiveRecord.ajc$interMethod$com_project_lib_model_extensions_i18n_Locale_Roo_Jpa_ActiveRecord$com_project_lib_model_extensions_i18n_Locale$entityManager(Locale_Roo_Jpa_ActiveRecord.aj:1)
at com.project.lib.model.extensions.i18n.Locale.entityManager(Locale.java:1)
以前,当我以下列方式定义 DataLoader 时它正在工作:
@Component
@Configurable
public class DataLoader implements ApplicationListener
但使用原始类型不是一个好习惯,所以我想切换
我怎样才能让它工作?
春季版:3.1