Basic Setup and First Program

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 22

Basic setup and

first program
Basic configuration
• Throughout this course we will use Eclipse
IDE
• Eclipse version should be Enterprise
Edition (JEE)
• We will need to add Spring Framework
and Maven to the Eclipse
• Maven should be already included in
newer Eclipse versions
Basic configuration
• Easiest way to install additional libraries is
through Eclipse Marketplace
Basic configuration
• Maven Integration
Basic configuration
• Maven is a tool that can now be used for building and
managing any Java-based project.
• Maven attempts to deal with:
– Making the build process easy
– Providing a uniform build system
– Providing quality project information
– Providing guidelines for best practices development
– Allowing transparent migration to new features
Basic configuration
• Maven allows a project to build using its project object
model (POM) and a set of plugins that are shared by all
projects using Maven, providing a uniform build system.
• Maven provides plenty of useful project information that is
in part taken from your POM and in part generated from
your project’s sources. For example, Maven can provide:
– Change log document created directly from source control
– Cross referenced sources
– Mailing lists
– Dependency list
– Unit test reports including coverage
Basic configuration
• Maven aims to gather current principles for best
practices development, and make it easy to guide a
project in that direction.
• For example, specification, execution, and reporting of
unit tests are part of the normal build cycle using Maven.
Current unit testing best practices were used as
guidelines:
– Keeping your test source code in a separate, but parallel source
tree
– Using test case naming conventions to locate and execute tests
– Have test cases setup their environment and don’t rely on
customizing the build for test preparation.
Basic configuration
• After adding Maven Integration, or if it was already included in
Eclipse, it is usually needed to rebuild indexes for the first time
• On the top menu bar, open Window -> Show View -> Other
• In the Show View window, open Maven -> Maven Repositories
Basic configuration
• In the window that appears, right-click on Global
Repositories and select Go Into
• Right-click on "central (
http://repo.maven.apache.org/maven2)" and select
"Rebuild Index"
– Note that it will take a while to complete the download
• Once indexing is complete, Right-click on the project
-> Maven -> Add Dependency and start typing the name
of the project you want to import (such as "hibernate").
– The search results will auto-fill in the "Search Results" box below.
Basic configuration
• Spring also needs to be added to Eclipse
First project
• How to create first Spring project using Maven?
First project
First project
• Group Id – package name
• Artifact Id – program name
First project
• Maven project setup
First project
• Add dependencies
First project
• POM looks like this:
First project
• Create simple Person.java class
First project
• Add beans.xml file
First project
• Open beans.xml, select beans and add new bean for Person class
First project
• You should add id to this bean and connect it to the class
Person
First project
First project
• Create simple App.java class

You might also like