Skip to content
Advertisement

Tag: spring

Error creating bean with name and Singleton bean creation not allowed

I am getting the following exception when I execute the code via JUnit Test Case org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name ‘somarFactory’: Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) Could someone advise what might be the issues? Answer Go to

Spring DeferredResult setResult causing 404

I am using the new spring 3.2 async servlet requests. All works well except in this one scenario… When someTest() is true spring/tomcat returns a 404. I am not sure how I should go about this or why this happens? I assume it might be because the Servlet Async Context has already been created. Is this a bug or am

Bind elements to a list with spring mvc ModelAttribute

The question is based on getting a spring model attribute list element using an index from javascript on which explains that each name of the html element must contain an index. Example user[0] I have a form that allows the user to dynamically add or remove elements from the list before submitting it. Let me put an example: we add

Thymeleaf: how to get URL attribute value

I can’t find any solution for getting attribute from URL using Thymeleaf. For example, for URL: I need to get “error” attribute value. Also I’m using SpringMVC, if it could be helpful. Answer After some investigation I found that it was Spring EL issue actually. So complete answer with null checking is:

How to close a spring ApplicationContext?

After my application finishes I want to close the spring context. The relevant code has an ApplicationContext reference but I couldn’t find a close method. Answer Downcast your ApplicationContext to ConfigurableApplicationContext which defines close() method:

MySQL Batchupdate() with ON DUPLICATE KEY UPDATE

I am using batchUpdate() to insert multiple records in a table. As per the requirement, if there is a duplicate value for a primary key while inserting it should be updated with the latest received data, hence I was trying to use ON DUPLICATE KEY UPDATE in INSERT statement. The ON DUPLICATE KEY UPDATE works good when I use a

alternative to GrantedAuthorityImpl() class

I want an alternative to GrantedAuthorityImpl() class. I want this in spring security implementation. GrantedAuthorityImpl() class is deprecated. Hence I want an alternative solution to it. My code : Answer The class GrantedAuthorityImpl has been deprecated – you can use SimpleGrantedAuthority instead:

What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?

What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA? When I see the examples on the web, I see them there used kind of interchangeably. What is the difference between them? Why would you want to use one over the other? Answer JpaRepository extends PagingAndSortingRepository which in turn extends CrudRepository. Their main functions are: CrudRepository mainly

SpringJUnit4ClassRunner class not found

i am trying to create a unit test using SpringJUnit4ClassRunner but everytime i execute the test it says it cannot find SpringJUnit4ClassRunner using mvn install. here is my code Here is my POM file: i am using springSource tool suit IDE to develop this spring mvc app and on the IDE it highlights SpringJUnit4ClassRunner as a error saying it cant

Advertisement