Grails 中的加载时间编织
我正在尝试在 Grails 项目中使用加载时编织,以便能够序列化和反序列化对象并自动注入 spring 依赖项。经过一番搜索后,我发现 简单的示例,这似乎按预期工作。但是在将相同的配置应用于一个简单的 Grails 项目后,我遇到了很多错误。例如:
[TomcatInstrumentableClassLoader@413a2870] error at org/springframework/web/servlet/theme/AbstractThemeResolver.java::0 class 'org.springframework.web.servlet.theme.AbstractThemeResolver' is already woven and has not been built in reweavable mode
为了测试这个,我创建了一个新的 grails 项目并更改了 applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:spring-configured />
<context:load-time-weaver aspectj-weaving="autodetect" weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
在这个文件中我还创建了一个新的 bean:
<bean class="be.testweaving.Person" scope="prototype">
<property name="name" value="Timon"/>
</bean>
这定义了 Person
类的原型并注入值 Timon
到 name
属性中。
我使用 grails war 将其打包为 war 并将其部署在 tomcat 服务器上。该tomcat的lib目录中有org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
,部署后我看到了上面提到的大量错误。
有人能够在 Grails 中配置加载时间编织吗?
I'm trying to use load time weaving in a Grails project in order to be able to serialize and deserialize an object and to have automatic injection of spring dependencies. After some searching I found an easy example and that seems to work as expected. But after applying the same configuration to a simple Grails project I get a lot of errors. For example:
[TomcatInstrumentableClassLoader@413a2870] error at org/springframework/web/servlet/theme/AbstractThemeResolver.java::0 class 'org.springframework.web.servlet.theme.AbstractThemeResolver' is already woven and has not been built in reweavable mode
To test this I created a new grails project and changed the applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:spring-configured />
<context:load-time-weaver aspectj-weaving="autodetect" weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
In this file I also created a new bean:
<bean class="be.testweaving.Person" scope="prototype">
<property name="name" value="Timon"/>
</bean>
This defines a prototype for the Person
class and injects the value Timon
into the name
property.
I package this as a war using grails war
and deploy this on a tomcat server. This tomcat has the org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
in his lib directory and after the deployment I see a huge list of the errors I mentioned above.
Has anyone been able to configure load time weaving in Grails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不通过元类注入你的属性呢?
Why don't you just inject your property via metaclass?