Thursday, January 23, 2014

Spring Course: V119 - V125 Logging and Testing

Video 119: Adding Log4j Logging & V120 Resolving Logging Conflict
1- Add log4j jar file to pom.xml
2- Add log4j.properties somewhere in your classpath


3- add -Dlog4j.debug to jvm parameters in order to see how everything is loaded

4- sometimes you may have a problem with logging because other libraries may also use other logging jars, Spring uses Jakarta Common Logging Api, which basically looks for logging implementation, so in case you have a library that uses Log4j for debugging and another one uses slf4j for example, spring will be confused and may use one not the other.

Video 121: using logging

Video 122: Creating a MySQL Test Database
here we create a MySQL database just for testing

Video 123: Using Spring Profiles
here we add spring-test dependency to pom.xml
and we defined some profiles, so we will have production profile and development profiles.

so we can set some beans to be initiated in productions and others for developments

to do that
1- in web.xml

we add spring.profiles.active

2- now you can write this

Video 124: Creating JUNIT Tests
Here we added new profile which is Dev, so we can use it for testing,
then you can add this:


i dont like the way he implemented this, i prefer to create new project for testing and add dependency to the project we want to test.


Video 125: Coding Junit DAO Tests
nothing new here

No comments:

Post a Comment