Reputation: 338
I have a REST API with Spring managed EntityManager. When I try to close it with
@Autowired
EntityManager em.
em.close();
I receive IllegalStateException which is normal because the Spring doc. says so.
My question is: which is the correct way to terminate a REST application created with Spring Boot? Should I be 'disturbed' by this exception?
I googled it a lot but didn't find clear information.
EDIT: what is disturbing is the fact, that if I shut down my application (e.g. in Tomcat) I receive the same IllegalStateException.
Upvotes: 0
Views: 889
Reputation: 131
You don't need to close the EntityManager
connection. It will be managed by Spring. So you need to remove the line:
em.close()
Upvotes: 2