我正在使用 JPA 将实体持久化到我的数据库中。Id 列由 Persistable 类表示
@MappedSuperclass
public class Persistable {
@Id
@GeneratedValue(generator = "CustomGenerator")
@GenericGenerator(name="CustomGenerator", strategy = "parohia.imported.domain.UseExistingOrGenerateIdGenerator")
Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
Run Code Online (Sandbox Code Playgroud)
}
我的自定义生成器是这样的:
public class UseExistingOrGenerateIdGenerator extends IdentityGenerator implements IdentifierGenerator {
@Override
public Serializable generate(SessionImplementor session, Object object)
throws HibernateException {
// TODO Auto-generated method stub
Serializable id = session.getEntityPersister(null, object)
.getClassMetadata().getIdentifier(object, session);
return id != null ? id : super.generate(session, object);
}
Run Code Online (Sandbox Code Playgroud)
} …
我正在开发一个反应应用程序。对于开发,我使用 webpack 开发服务器。我的后端应用程序是一个弹簧靴。当我发出请求但未通过身份验证时,后端会将我重定向到登录页面 ( localhost:8080/login)。
我的 webpack 开发服务器在端口上运行3000。我所有的 api 调用都使用来自开发服务器的代理重定向到后端。
devServer: {
historyApiFallback: true,
contentBase: './',
proxy: [{
context: ["/api"],
target: "http://localhost:9090"
}],
changeOrigin: true,
secure: false
Run Code Online (Sandbox Code Playgroud)
例如,当我访问受保护资源但未通过身份验证时,localhost:3000/api/test我被重定向到localhost:8080/login2 个请求:一个 302 请求和一个 200 请求到/login. 问题是开发服务器实际上并没有进行重定向,也没有显示登录页面。当从我的 Spring Boot 应用程序提供内容时,重定向就完成了。
这是与 webpack dev server 相关的问题还是我对代理机制的理解有问题?