Project Setup
In this
tutorial I’ll use Spring Tool Suite 3.1 and JBoss 7.1 Final but they are not
required. You can use IDE and application server of your choice and configure
it by yourself.
Follow the
steps below:
1. Click Alt + Shift +N or File -> New and
choose Project…
2.
Spring -> Spring
Template Project -> Next
3. Choose Spring MVC Project ,
click Next and confirm Yes
4. Insert your project name and default
java package and click Finish
Your
project will be created from predefined template. It is ready to use and we’ll
test it on JBoss 7.
Setup Application Server in STS
You need to
download JBoss from here
and unpack it on your local file system. Then follow the steps:
1. Go to Servers tab in STS
2.
Right click ->
New -> Server
3. Find JBoss 7.1 in the tree. If it is
not here click Download additional adapters and install plugin for this
concrete container. Change server host
name and server name if you want and
click Next
4. Select your JBoss location on your
hard drive and jdk’s installation. Click Finish.
JBoss is
ready to run.
Deploy Application on Server
To deploy Spring
MVC app on JBoss 7 we’ll use eclipse plugins support. It will automatically
build, compile project and copy war file to jboss deployments folder.
1. Run JBoss
2. Using Drag and Drop put your app on
server icon.
3. See logs
INFO
[org.springframework.web.servlet.DispatcherServlet] (MSC service thread
1-3) FrameworkServlet 'appServlet': initialization completed in 657 ms
INFO [org.jboss.web] (MSC
service thread 1-3) JBAS018210: Registering web context: /springMVCtutorial
INFO
[org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559:
Deployed "springMVCtutorial.war"
Application
is deployed
4. Go to web browser and go to http://localhost:8080/springMVCtutorial/
Import existing project
Generally
you will be not creating new project using Eclipse / STS wizards. Probably you
will import it from existing sources. To use eclipse deployment support
imported maven project needs to be configured in STS. Environment has to know
that this is a web module and can be deployed to server.
1.
File -> Import…
2. Select Existing Maven Projects… and
click Next
3. Set root directory and Finish
To
make imported project be sure that project facets are selected like on the picture below. (project Properties -> Projects Facets)
Brak komentarzy:
Prześlij komentarz