简体   繁体   English

当多个用户使用系统时,依赖项注入冲突

[英]Dependency injection conflict when more than one user uses the system

I made a single Java Application using Tomcat(Prod) and Jetty(Dev) + Hibernate + Spring + Spring MVC + Fremarker I have a issue to solve, 'cause the users are reporting that only one user can do login without conflict. 我使用Tomcat(Prod)和Jetty(Dev)+ Hibernate + Spring + Spring MVC + Fremarker创建了一个Java应用程序。我有一个要解决的问题,因为用户报告说只有一个用户可以进行登录而不会发生冲突。 If a user does login and tries to create a new entity Payment, he have a successfull transaction. 如果用户登录并尝试创建新的实体“付款”,则表示他已成功完成交易。 But when another user does login, since then, nobody can create a new Payment. 但是从那时起,当另一个用户登录时,没有人可以创建新的付款。

There is no exception, a POST is executed, but seems like the Controller is not able for delivery the form to services classes. 也不例外,将执行POST,但似乎Controller无法将表单传递给服务类。

@MappedSuperclass
@Getter
@Setter
public abstract class AbstractEntity implements Persistable, Cloneable {

//code...

}

@Entity
@Getter
@Setter
public class Pagamento extends AbstractEntity{

//code...

}

@Component
@Transactional
public class PagamentoService {

//code...

}

@Controller
@RequestMapping("/payments")
public class PagamentosController {

//code...

}

Is everything okay about Annotations and CDI? 关于注释和CDI的一切都可以吗? What could to be happening? 可能会发生什么?

A common use case for that is using attributes of controller (or service, dao, etc.) classes. 常见的用例是使用控制器(或服务,Dao等)类的属性。 All those beans are singleton beans and are shared between all requests and sessions. 所有这些bean是单例bean,并且在所有请求和会话之间共享。 You should only use local variables in all those singleton beans - except of course for attributes that are common for the whole application ... 您只应在所有这些单例bean中使用局部变量-当然,对于整个应用程序共有的属性除外。

可能是因为您使用的是单连接数据源,所以一旦一个请求建立了连接,那么在第一个释放单个数据库连接之前,没有其他请求可以访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用具有多个实现的接口的 Spring 依赖注入 - Spring Dependency injection using interface with more than one implementation 分布式系统中的依赖注入 - Dependency Injection in Distributed System 为什么即使机器上运行了多个 java 应用程序也没有 JMX 冲突? - Why there is no JMX conflict even when more than one java application is running on the machine? 当多个构造函数具有 @Autowired 时,Spring 构造函数注入会引发错误 - Spring Constructor Injection throws an error when more than one constructor has @Autowired Mockito - 监视多个依赖项 - Mockito - Spying on more than one dependency 排除传递依赖超过一级 - Excluding transitive dependency more than one level 当 hashset 有多个具有重复值的对象时,hashset 如何使用 hashtable? - how hashset uses hashtable when hashset has more than one object with duplicated value? 一个项目中的依赖注入 - Dependency Injection in one project 当类存在于多个库中时,Eclipse会错误地选择JAR作为项目依赖项 - Eclipse makes wrong choice of JAR as project dependency when class presents in more than one library 如何在RecyclerView中使用光标适配器制作一张以上的卡? - How to make more than one card in RecyclerView that uses cursor adapter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM