Sunday 16 November 2014

Building WAR file using MAVEN

Hi, Today I'm going talk about how to build a WAR file using maven. To build a war using maven, follow below steps,
Step 1:
Download maven, and set it in Path like C:\apache-maven-3.1.1\bin; (installed location)

Step 2:
Create a system variable JAVA_HOME and set it with the location where jdk installed, if java installed on Program Files then C:\Progra~1\Java\jdk1.7.0_71;, or on Program Files(x86) then C:\Progra~2\Java\jdk1.7.0_71; (because it won't take spaces in the directory name).

Step 3:
Open command prompt, and go to your web application location,(where you find pom.xml), then run below command,
mvn package

After that go to your web application folder open target folder inside it there you can find the created war file.

Thanks.. 

Difference between CLASSPATH and PATH

So many people are getting confused of Classpath and Path. But it is very simple to understand. A Classpath describes where the required .class files are located. And Path describes where there the required binary executables are located.

For example if we want compile/run any java program we have to set like, C:\Program Files\Java\jdk1.7.0_71\bin in the Path. Because the required executables are available under bin directory.

Wednesday 12 November 2014

Best Connection pooling Technique: HikariCP

We have different connection pooling techniques among them HikariCP performance is well when compared to others. Because of the following,


  • Test connections at getConnection()
  • Closes abandoned Statements at Connection.close()
  • Executes a rollback() when Connections returned to the pool
  • Clears SQL warnings before returning a Connection to a client
  • Resets connection state
  • Traps and examines SQLException objects for disconnection errors

for more information regarding this you can refer here

Tuesday 11 November 2014

A Class can't implement multiple Interfaces

Every one knows that a java class can implement multiple interfaces, but there is a case where it is not possible to implement multiple interfaces. For example take two interfaces TestA and TestB having same method but different return types like,

interface TestA{

void m1();

}


interface TestB{

int m1();

}

Then it is not possible to create a class implementing these two interfaces, because a class can't allow two methods with same signature but different return types.

Thanks..

Monday 10 November 2014

Configuring multiple Spring ViewResolvers

View Resolvers are used to render models in browser, without being tied to any specific view technology. We can configure multiple View Resolvers in our Spring configuration file like,

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<beans:bean class="org.springframework.web.servlet.view.XmlViewResolver">
<beans:property name="location">
                  <beans:value>/WEB-INF/spring-views.xml</beans:value>
                </beans:property>
</beans:bean>

In this case when the Controller returned a view name, which view resolver strategy will be used?? For this we have to specify priority through an 'order' property where lower order value has a higher priority. Like,

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
                <beans:property name="order" value="0"></beans:property>
</beans:bean>

<beans:bean class="org.springframework.web.servlet.view.XmlViewResolver">
<beans:property name="location">
                  <beans:value>/WEB-INF/spring-views.xml</beans:value>
                </beans:property>
                <beans:property name="order" value="1"></beans:property>
</beans:bean>


Thanks..