Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Separate database configuration

$
0
0
Hey guys,

I've been dealing with this problem for couple of days now and I can't get around to solve it. The working setup that I need is: two separate databases, one for JUnit testing and the other for the pure application access purposes.
I've been using MySQL for the the application part, since I need the full control and support and the other database that I am considering is Derby or H2 since the speed is essential here.

Okay, the MySQL database is working as it should, the JUnit tests are 100% success when I run them through
and there are no problems there. However, when I try to configure my project with the second database, the
problems arise. I've been searching for answers and I found the following setup when adding additional database to your spring-roo project:

1. Additional ApplicationContext that I've put in: src/test/resources/META-INF/spring/ and named as: applicationContextTest.xml
2. As well as additional ApplicationContextSecurity file that I've created in the same folder and named applicationContext-securityTest.xml
3. Necessary changes in pom.xml, persistence.xml and web.xml files
4. And also I've configured @ApplicationContext in JUnit test class to use appropriate files
5. Also separate database_test.properties located in the same folder as mentioned above

The exception that I am constantly getting is that the EntityManager has not been injected. I know this is a scarce information to work on, but I just want to get few opinions before, lets say, posting the whole code and the files that go along so that you people can see if I have made some silly mistakes(which at this point I am sure I haven't) or that I am missing some additional changes that need to be made.

Thank you very for your time invested in this.

Cheers,
Marko

Viewing all articles
Browse latest Browse all 297

Trending Articles