org.springframework.security.core.GrantedAuthority
类,因此在 pom.xml 中它具有 org.springframework.security. 的 Maven spring-security-corepackage
命令时,我收到消息:类型没有源代码 org.springframework.security.core.GrantedAuthority;你忘了吗 继承一个必需的模块?
您能帮我找出导致此错误的原因以及我该如何解决吗?
要重现问题,您可以按照我所做的步骤操作:
我使用 GWT Archetypes 创建了一个名为
GWTRPCModular
的基本项目;和:
该项目由 3 个模块生成:
GWTRPCModular-client
、GWTRPCModular-server
和 GWTRPCModular-shared
。
我为 DTO 添加了一个名为
GWTRPCModular-model
的模块 (类似于我的遗留项目) 并在 pom.xml 中添加了必要的依赖项。
我将
<source path="model" />
包含在 *.gwt.xml 文件中。
我创建了
UserSessionDTO
班级
import java.util.Collection;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
public class UserSessionDTO extends User {
private static final long serialVersionUID = -6391317902265663080L;
public UserSessionDTO(String username, String password, Collection<? extends GrantedAuthority> authorities) {
super(username, password, authorities);
// TODO Auto-generated constructor stub
}
}
mvn clean install
mvn package
,消息出现了:...
[INFO] --- gwt-maven-plugin:1.0.1:compile (default-compile) GWTRPCModular-client ---
[INFO] Compiling module com.foo.gwtmodular.App
[INFO] Tracing compile failure path for type 'com.foo.gwtmodular.model.dto.UserSessionDTO'
[INFO] [ERROR] Errors in 'com/foo/gwtmodular/model/dto/UserSessionDTO.java'
[INFO] [ERROR] Line 8: No source code is available for type org.springframework.security.core.userdetails.User; did you forget to inherit a required module?
[INFO] [ERROR] Line 12: No source code is available for type org.springframework.security.core.GrantedAuthority; did you forget to inherit a required module?
...
如果您需要其他任何内容来审查此案例,请告诉我。
提前感谢您提供的任何帮助!
在您的 GWT (*.gwt.xml) 模块文件中,您还需要一个
<inherits>
标签用于此 spring 依赖项。
虽然这个 spring 库可能没有自己的 GWT 模块文件,所以你需要创建自己的。在您的客户端项目中,您可以创建一个包,例如
org.springframework.security
,为 spring 库创建一个 GWT 模块文件并将其放入包中。然后你可以在你的主 GWT 模块文件中继承它
参考这个问题/答案: https://stackoverflow.com/a/70538165/1920835