Thursday, January 30, 2020

Controller not scanning in SpringBoot

If our controller is not getting identified/mapped by Tomcat while deploying any War/jar,  we need to make sure that we have created a class extending SpringBootServletInitializer.
Based on google, I tried defining basepackage with @SpringBootApplication but did not work but defining this class worked.

Here is the example.





import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

   @Override   protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
      return application.sources(ApplicationSample.class);
   }

}

Monday, January 6, 2020

Encrypt properties value for spring boot application

Encrypt password value in properties file in spring boot application

Now a days, it is very important to encrypt the value that we configure in properties files to secure the data.
To encrypt the values in properties file specially in Spring based web application we can use available framework (jasypt) as below:
For example: We have folloing properties value in properties files

db.password=12345

  1. Add   maven plugin in pom as below
    <dependency>
       <groupId>com.github.ulisesbocchio</groupId>
       <artifactId>jasypt-spring-boot-starter</artifactId>
       <version>2.0.0</version>
      </dependency>
  2. Now, configure jasypt encryptor password and algorithm in application properties files as below:
    jasypt.encryptor.password=secretKey
    jasypt.encryptor.algorithm=PBEWithMD5AndDES
  3. Now, generate encrypted value of db.password (12345) using the jar and define in properties files as below:
    To generated encrypted value we need to  use jasypt jar file, password and algorithm as below in cmd:
    java -cp jasypt-1.9.2.jar  org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI password=secretKey input=12345 algorithm=PBEWithMD5AndDES

    When we run above command, it will generate  encrypted value as below:isUphpA4A5/R+4nPV7tfrQ==

Example:
C:\user\.m2\repository\org\jasypt\jasypt\1.9.2>java -cp jasypt-1.9.2.jar  org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI password=secretKey
 input=12345 algorithm=PBEWithMD5AndDES

----ENVIRONMENT-----------------

Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 24.80-b11

----ARGUMENTS-------------------

algorithm: PBEWithMD5AndDES
input: 12345
password: secretKey

----OUTPUT----------------------

isUphpA4A5/R+4nPV7tfrQ==




Now, copy above encrypt value to properties file as below with ENC(..):
db.password=ENC(isUphpA4A5/R+4nPV7tfrQ==)

Saturday, February 11, 2017

Code quality tool Sonar presentation


Monday, January 13, 2014

How to update multiple column from another tablein oracle using single query

I was trying to find out single query to update multiple column of one table from another table based on some values. Finally I came up with following query tat work properly in oracle.

UPDATE T1
SET (T1.C1,
     T1.C2,
     T1.C3)=
  (SELECT T2.C1,
          T2.C2,
          T2.C3
   FROM T2
   WHERE T1.C4 = T2.C4
     AND T1.C5= T2.C5)

Monday, May 21, 2012

Stop updating indexes for maven in eclipse

eclipse - M2E plugin continually updating index,(Prevent downloading repository index updates on startup)

 

How to stop  updating indexes for maven in eclipse? Most of the developer friends want the
answer to speed up the eclipse IDE.

Check option into the properties of maven.

 Go to Window-Preferences-Maven and there uncheck this "Download repository index updates on startup" option.

Thursday, May 10, 2012

How to uninstall (GWT) Google Plugins from Eclipse?



Uninstall/update eclipse plugins

Uninstall Google Plugins from eclipse (Google Web Toolkit).

In Eclipse ,
Go to Help > About > Click on Installation Details


Select name of the software from the lists and click Uninstall button at the bottom as below image.


From here, we can install, update any eclipse plugins easily.