具有多模块 Maven 项目的 GWT ServiceLocator
我有一个多模块 GWT 项目,我想使用 ServiceLocators。我有3个模块:
- “客户端”依赖于共享
- “共享”
- “服务器”依赖于共享
我这样编写了ServiceLocator:
public class TreeServiceLocator implements ServiceLocator {
public Object getInstance(Class<?> clazz) {
return new TreeService();
}
}
并将此类放置在“共享”模块中,因为ServiceLocator具有包com.google.gwt.requestfactory。共享。但是,当我编译时,会抛出错误,因为 TreeService 是在“服务器”模块中实现的,因为我需要它从服务器返回 bean 并与 Spring 交互等。
我应该在哪个模块中实现 TreeServiceLocator?另外,如果我尝试包含“共享”模块中的“服务器”,maven 将引发循环依赖错误。
谢谢你!
I've a multi-module GWT project and I'd like to use ServiceLocators. I have 3 modules:
- "client" depends on shared
- "shared"
- "server" depends on shared
I wrote the ServiceLocator like this:
public class TreeServiceLocator implements ServiceLocator {
public Object getInstance(Class<?> clazz) {
return new TreeService();
}
}
and placed this class in the "shared" module because ServiceLocator has the package com.google.gwt.requestfactory.shared. However, when I compile this throws an error because TreeService is implemented in the "server" module since I need it to return beans from the server and interact with Spring, etc.
In which module should I implement the TreeServiceLocator? Also, maven will throw a circular dependency error if I try to include "server" from the "shared" module.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
TreeServiceLocator
放在server
包中,并使用@ServiceName
注释而不是@Service
。这些注释具有相同的效果,但前者使用字符串文字而不是类文字。如果服务器类型在 GWT 编译器的类路径上不可用,这将避免 GWT 编译出现问题。Place the
TreeServiceLocator
in theserver
package, and use a@ServiceName
annotation instead of@Service
. These annotations have the same effect, but the former uses string literals instead of class literals. This will avoid problems with the GWT compile if the server types aren't available on the classpath of the GWT compiler.