[main] WARN GenericApplicationContext:591 – Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name ‘dataSource’ defined in class path resource [.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

This is an issue faced if you have not dbcp jars in your classpath. For maven the simple fix is to add the dependency to the pom.xml Commons dbcp 2 is also avaliable. But for this make sure that you update config to use

How to set an hour or a minute in a date

How to set the hour in a date? Here is the example to do so Here is an example of setting a minute in a date Hopefully you have found this useful

Get the difference in months for a date.

If you want to know how many months is the difference between 2 dates. Here is the code for you I think the code is self explanatory. Using ChronoUnit.MONTHS.between() we can find the difference between the dates. Please do note how we use the LocalDate. If you need to handle specific locales, you would have … Read more

How to set Date to midnight in Java

Here is piece of the code that will help you with setting the Date to midnight in Java We take the Calender instance and set the time to the user date. After that we set the hour, minute, second and millis to 0. That gives us the Date set to midnight.

How to integrate different systems

The data that comes from various systems into an application should be handled in a way that we have to do minimum of the work for integration with different systems that provide data. Defined a common interface. All the systems that provide data have to provide a database that follows the interface specification. Application should … Read more

Search an enum by a unique attribute

I was recently defining an enum with some keys. But the enum needed more than a key. It also needed a configuration parameter that would define if this key has some special feature avaliable. So I defined the enum with a constructor that had 2 inputs, the key and the configuration boolean attribute. Now the … Read more

How should dependencies be managed in maven

Multi module projects in maven are a great thing. But have you ever faced issues with multi module projects. With lots of smaller services and 1 parent for all the services. Some services at any point may need different dependencies or different versions of same dependencies. So it be better have <optional> on dependencies that … Read more