Monday, June 6, 2016

Eclipse Issues

Issue: 
"Java compiler level does not match the version of the installed Java project facet."

Resolution:
Go to project >> Properties >> Project Facets and change the facets to required java version

Issue:
Unbound classpath container: 'JRE System Library' in project 'XYZ'

Resolution:
Go to Project >> build path >> Configure Buildpath >> Libraries >> Add Library >> JRE System Library >> Select an existing library

Issue:
"Cannot change version of project facet Dynamic Web Module to 3.0"

Resolution:
Change the attributes of web-app tag in web.xml file of the project to point to module 3.0


Issue:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

Resolution:
Add the dependency for java servlet api to the classpath

Issue:
How to enable to write mult-line string in eclipse

Resolution:
Go to Windows >> Preferences >> Java >> Editors >> Tying and Make sure that check box "Escape text when pasting into a string literal" is checked

Issue:
Warning message in an XML file "No grammar constraints (DTD or XML Schema) referenced in the document."

Resolution:
Just add <!DOCTYPE xml> below the tags <?xml version="1.0" encoding="UTF-8"?>

Issue:
While compiling maven project getting exception "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project {project name}: Compilation failure: Compilation failure"

Resolution:
Go to pom.xml and remove <scope>test</scope> all the dependencies.

Issue:

Resolution:



Thursday, June 2, 2016

MAVEN

MAVEN is an innovative software project management tool that provides new concept of a project object model (POM) file to manage project’s build, dependency and documentation. The most powerful feature is able to download the project dependency libraries automatically.

Steps to install MAVEN:-
  • Download the  binary file form apache's site
  • Unzip the zip file and add to the environment variable.
  • To confirm installation use mvn -version on command prompt.
A simple maven project consists of following folder structure
  •  project
    • src
      • main
        • java (the source code)
        • resources
      • test
        • java (the unit test code )
        • resources ()
    • pom.xml (the configuration file containing the information to build the project)
POM.xml stands for Project Object Model and it has the below structure

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PROJECT_NAME_IN_PACKAGE_NAME_STYLE</groupId>
<artifactId>NAME_OF_JAR</artifactId>
<version>VERSION_OF_JAR</version>
</project>

MVN Install:-
  • It is used to install the package to local repository so that it can be referenced by several projects
MVN package:-
  •  It is used to build the project
mvn archetype:generate:-

To create a java project in java 
mvn archetype:generate
-DgroupId=com.anshul.ws
-DartifactId=MyWebService
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false

To support eclipse

mvn eclipse:eclipse -Dwtpversion=2.0
Life cycle of Maven:-
Like we have targets in case of Ant , we have phases in maven

Features of MAVEN:-
  • Build process becomes very easy
To create a web-app using maven
  1. Using command prompt go to the directory where project needs to be created
  2. Type below
    mvn archetype:generate -DgroupId=org.arsoft.projects.sood -DartifactId=arsood -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
  3. To be able to access the project on eclipse go to the directory and run command
    mvn eclipse:eclipse -Dwtpversion=2.0
To create a Java project:

mvn archetype:generate -DgroupId=org.arsoft.projects.sood -DartifactId=arsood -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

To create an EJB project:

mvn archetype:generate -DgroupId=com.arsoft.projects -DartifactId=Common -DarchetypeArtifactId=ejb-javaee6 -DinteractiveMode=false

Understanding POM
  1. It stands for Project Object Model and is the fundamental unit of work in maven.

SpringBoot Application Event Listeners

When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...