Thursday, May 25, 2017

STS : Spring Roo Project Creation Gives Error mojo codehaus

Those who started working with Spring-Roo for faster development but facing difficult to set up STS Spring Roo Project Environment.
It may turn to roadblock if below problems cannot be resolved:
  • Code is not compilable.
  • Maven Dependencies are not shown in project configurations.
This is having 3 fixes & you can start your development:
  • Update POM file for correct aspect version : 1.9 for JDK 1.8 onwards
    • <aspectj.plugin.version>1.9</aspectj.plugin.version>

  • Configure correct location for maven settings.xml 
    • By default it will search in %USER_PROFILE%\.me\settings.xml
    • So set to MVN 3.5+ : %MAVEN_HOME%\conf\settings.xml

  • Maven Profile must be "development"
    • Follow Below instructions for Maven profile update:

accepted

You can activate the maven profile at the Eclipse by using the following step: -

  1. Right click at your project and select properties .
  2. At the Properties windows select Maven.
  3. At the right hand panel you will see Active Maven Profiles text box.
  4. Please enter your profile name, e.g. development or production.

--
----
Thanks & Regards,
Abhijeet
​.

Monday, March 6, 2017

[Performance] java Map.containsKey() redundant when using map.get()


In most of our code, we generally use HashMap.

 

Most of the operation we do:

·         Prepare HashMap to process.

·         Process the HashMap.

·         Retrieve data from Map.

 

Following use-case needs to be avoided:

Most of the time to avoid NPE (NullPointerException) code is getting handled in below way:

 

 

 

          dataMap.contains(key) ? dataMap.get(key) : someObject;

 

 

Avoid using above as it may impact performance because both below APIs do same operation:

·         containsKey()

·         get(key)

 

SO optimized code for avoiding redundant Map processing:

 

 

  Object  mappedValue = dataMap.get(key);       // fetch only once

 (mappedValue == null) ? someObject: mappedValue;

 

 

 

This is definitely useful for dealing bigger DataSet.

 

Also don't forget to use collection.clear(); if data is no more required.

 

 

III

Best Regards,

Abhjeet.