我在grails 3中有一个项目,该项目具有项目spring依赖项,在spring项目中,配置了xml bean。应该如何在grails体系结构中导入bens?
build.gradle
dependencies {
compile (project(':spring-project')) { transitive = false }
}
settings.gradle
includeFlat 'spring-project'
我尝试了以下方法:
在resources.groovy中加载bean:
beans = {
importBeans('path/to/beans-definition.xml')
}
在resources.xml中:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<import resource="path/to/beans-definition.xml" />
</beans>
此外,在spring项目中,还配置了使用Java注释的bean。即使通过在相应扫描中设置spring项目程序包,bean也无法在grails应用程序中工作。
@ComponentScan(basePackages = ["package.spring.project.beans"])
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
}
但是,没有任何效果。任何帮助将不胜感激..