我正在开发一个具有独立模块的项目。 后端用于管理员,客户端用于用户,核心用于在之间共享DAO层strong>后端和客户端。
后端模块使用GWT,客户端使用Spring MVC。在后端模块中,核心模块被deployment assembly包含。我的服务器端,DAO 由 Spring 注入(inject)。
在core模块中创建的所有bean(POJO)。我的问题是我想在我的 gwt 项目(后端模块)中或使用 RPC 调用时使用来自 core 模块的这些 bean。
我尝试作为How can share bean from external library to GWT client?的答案问题但还没有满足。我收到以下错误
No source code is available for type com.mycom.core.business.bean.TestBean; [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
这是我努力的代码...
TestBean.java
public class TestBean {
private int id;
public final int getId() {
return id;
}
public final void setId(int id) {
this.id = id;
}
}
beans.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name='com.google.gwt.user.User'/>
<source path="com.mycom.core.business.bean.TestBean"/>
</module>
将我的 App.gwt.xml 中的 beans.gwt.xml 继承为 <inherits name='com.mycom.backend.beans'/>
。我缺少什么?
Edit: Add sample project file
现在我创建并上传了示例模块。您可以从google-drive URL下载.此存档文件包含后端和核心模块。
core 模块是从 Eclipse IDE 创建为简单的 java 项目。
后端模块由 gwt-ecliplse 插件创建(2.7 gwt 版本并包含生成的代码),并添加 Dynamic Web Module 2.5 项目界面。
最后,我使用GWT-Eclipse 插件构建并运行,您可以检查
类路径
源查找路径
模块
以下是我的控制台中的错误日志
Super Dev Mode starting up
workDir: /var/folders/mt/5287l4j94jd9rfqwqdqxr9zw0000gq/T/gwt-codeserver-7296341534601698800.tmp
Loading Java files in com.mycom.backend.App.
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Finding entry point classes
Tracing compile failure path for type 'com.mycom.backend.client.Backend'
[ERROR] Errors in 'file:/Applications/springsource/workspace/backend/src/com/mycom/backend/client/Backend.java'
[ERROR] Line 41: No source code is available for type com.mycom.core.business.bean.TestBean; did you forget to inherit a required module?
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[WARN] Server class 'com.google.gwt.dev.shell.jetty.JDBCUnloader' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/Users/cataclysm/Desktop/eclipse%20(Luna)/Datas/gwt-2.7.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/Users/cataclysm/Desktop/eclipse%20(Luna)/Datas/gwt-2.7.0/doc/helpInfo/webAppClassPath.html
最佳答案
GWT 编译进程应该可以访问核心模块的源路径。确保将其添加到类路径或源查找路径中。
关于java - GWT : How to use beans from separate module?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28447064/