Apache Maven – as build tool : Maven with WebApplication
Maven with Web Application |
mvn command for creating Web based java project
Syntax :
mvn archetype:generate -DgroupId={project-packaging}
-DartifactId={project-name}
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
It will tell Maven to create a Web based Java project from the Maven maven-archetype-webapp template. If you ignore the archetypeArtifactId option, a huge list of the Maven templates will be listed.
Example:
mvn archetype:generate -DgroupId=com.javaskool -DartifactId=HelloWorldWebExample -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
D:\>md workspaceMaven
D:\>cd workspaceMaven
D:\workspaceMaven>mvn archetype:generate -DgroupId=com.javaskool -DartifactId=HelloWorldWebExample -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources
@ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources
@ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
en-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar (4 KB at 1.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
en-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom (533 B at 1.1 KB/sec)
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
maven-archetype-webapp:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.javaskool
[INFO] Parameter: packageName, Value: com.javaskool
[INFO] Parameter: package, Value: com.javaskool
[INFO] Parameter: artifactId, Value: HelloWorldWebExample
[INFO] Parameter: basedir, Value: D:\workspaceMaven
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: D:\workspaceMaven\HelloW
orldWebExample
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.880 s
[INFO] Finished at: 2015-02-19T16:57:03+05:30
[INFO] Final Memory: 9M/27M
[INFO] ------------------------------------------------------------------------
D:\workspaceMaven>
Here, a new web based Java project named “HelloWorldWebExample” would get created, and as well as the entire project directory structure is created automatically as below.
Here is the complete directory structure.
|HelloWorldWebExample
| |____pom.xml
| |____src
| | |____main
| | | |____resources
| | | |____webapp
| | | | |____index.jsp
| | | | |____WEB-INF
| | | | | |____web.xml
A standard pom.xml is generated. This POM file is like the Apache Ant build.xml file.
It describes the entire project information, everything from directory structure, project plugins, project dependencies, how to build this project and etc.
You can read more about pom.xml on this official POM guide.
pom.xml file create by above command
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaskool</groupId>
<artifactId>HelloWorldWebExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>HelloWorldWebExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>HelloWorldWebExample</finalName>
</build>
</project>
index.jsp
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
Making Eclipse Project.
To make this as an Eclipse project, type below command on terminal :
Syntax :
mvn eclipse:eclipse -Dwtpversion=2.0
Note: The option -Dwtpversion=2.0 tells Maven to convert the project into an Eclipse web project (WAR), not the default Java project (JAR).
D:\workspaceMaven>cd HelloWorldWebExample
D:\workspaceMaven\HelloWorldWebExample>mvn eclipse:eclipse -Dwtpversion=2.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorldWebExample Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) > generate-resources @
HelloWorldWebExample >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) < generate-resources @
HelloWorldWebExample <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ HelloWorldWebExample
---
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: D:\workspaceMaven
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C
:\Program Files\Java\jre1.8.0_25
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "HelloWorldWebExample" to D:\workspaceMaven\Hel
loWorldWebExample.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.043 s
[INFO] Finished at: 2015-02-19T17:17:22+05:30
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
D:\workspaceMaven\HelloWorldWebExample>
After Running above command, Your project directory structure as below
It will help you to generate all project files that are required by Eclipse IDE. Now, you can open eclipse and import this project. To import the project into Eclipse IDE, select "File ->> Import… ->> General ->> Existing Projects into Workspace"
And then browse for the “D:\workspaceMaven\HelloWorldWebExample” folder as per this example. And your Maven java project is reddy in the eclipse as below.
You can update the java version 1.7 and JUnit versions by using below code in pom.xml. Update the JUnit from 3.8.1 to latest 4.11. and also we will add more dependency, so that we will able to create spring web application.
Change pom.xml as below
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaskool</groupId>
<artifactId>HelloWorldWebExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>HelloWorldWebExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.7</jdk.version>
<spring.version>4.1.1.RELEASE</spring.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.11</junit.version>
<jcl-over-slf4j.version>1.7.5</jcl-over-slf4j.version>
<logback.version>1.0.13</logback.version>
</properties>
<dependencies>
<!-- Unit Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!-- Spring Core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${jcl-over-slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
</dependencies>
<build>
<finalName>HelloWorldWebExample</finalName>
<plugins>
<!-- Eclipse project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Always download and attach dependencies source code -->
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<!-- Avoid type mvn eclipse:eclipse -Dwtpversion=2.0 -->
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<!-- Set JDK Compiler Level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- For Maven Tomcat Plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/HelloWorldWebExample</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
For convenience, you can declares maven-eclipse-plugin and configure wtpversion to avoid typing the parameter -Dwtpversion=2.0. Now, each time you use mvn eclipse:eclipse, Maven will convert this project into Eclipse web project.
Initially
mvn eclipse:eclipse –>> Eclipse Java project (JAR)
mvn eclipse:eclipse -Dwtpversion=2.0 –>> Eclipse Java web project (WAR)
Now onwards, only
mvn eclipse:eclipse –>> Eclipse Java web project (WAR)
After updating this file either you save the file in eclipse and it will help you to download all updted dependencies or you can enter the same command [mvn eclipse:eclipse] again on terminal. Below is the Eclipse project with updated dependencies.
D:\workspaceMaven\HelloWorldWebExample>mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorldWebExample Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) > generate-resources @
HelloWorldWebExample >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) < generate-resources @
HelloWorldWebExample <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ HelloWorldWebExample
---
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: D:\workspaceMaven
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C
:\Program Files\Java\jre1.8.0_25
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
Downloading: https://repo.maven.apache.org/maven2/junit/junit/4.11/junit-4.11-so
urces.jar
Downloaded: https://repo.maven.apache.org/maven2/junit/junit/4.11/junit-4.11-sou
rces.jar (148 KB at 39.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3
/hamcrest-core-1.3-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/
hamcrest-core-1.3-sources.jar (32 KB at 51.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-cor
e/4.1.1.RELEASE/spring-core-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-core
/4.1.1.RELEASE/spring-core-4.1.1.RELEASE-sources.jar (633 KB at 199.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/slf4j/jcl-over-slf4j/1.7.5
/jcl-over-slf4j-1.7.5-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/slf4j/jcl-over-slf4j/1.7.5/
jcl-over-slf4j-1.7.5-sources.jar (23 KB at 40.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.5/slf4
j-api-1.7.5-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.5/slf4j
-api-1.7.5-sources.jar (47 KB at 61.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/ch/qos/logback/logback-classic
/1.0.13/logback-classic-1.0.13-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/ch/qos/logback/logback-classic/
1.0.13/logback-classic-1.0.13-sources.jar (214 KB at 134.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/ch/qos/logback/logback-core/1.
0.13/logback-core-1.0.13-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/ch/qos/logback/logback-core/1.0
.13/logback-core-1.0.13-sources.jar (356 KB at 153.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-web
/4.1.1.RELEASE/spring-web-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-web/
4.1.1.RELEASE/spring-web-4.1.1.RELEASE-sources.jar (650 KB at 179.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-aop
/4.1.1.RELEASE/spring-aop-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-aop/
4.1.1.RELEASE/spring-aop-4.1.1.RELEASE-sources.jar (346 KB at 185.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/aopalliance/aopalliance/1.0/ao
palliance-1.0-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/aopalliance/aopalliance/1.0/aop
alliance-1.0-sources.jar (21 KB at 37.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-bea
ns/4.1.1.RELEASE/spring-beans-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-bean
s/4.1.1.RELEASE/spring-beans-4.1.1.RELEASE-sources.jar (655 KB at 265.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-con
text/4.1.1.RELEASE/spring-context-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-cont
ext/4.1.1.RELEASE/spring-context-4.1.1.RELEASE-sources.jar (1004 KB at 236.8 KB/
sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-exp
ression/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-expr
ession/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE-sources.jar (193 KB at 67.8
KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-web
mvc/4.1.1.RELEASE/spring-webmvc-4.1.1.RELEASE-sources.jar
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-webm
vc/4.1.1.RELEASE/spring-webmvc-4.1.1.RELEASE-sources.jar (736 KB at 82.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/jstl/jstl/1.2/jstl-1.2-sources
.jar
[INFO] Wrote settings to D:\workspaceMaven\HelloWorldWebExample\.settings\org.ec
lipse.jdt.core.prefs
[INFO] File D:\workspaceMaven\HelloWorldWebExample\.project already exists.
Additional settings will be preserved, run mvn eclipse:clean if you want
old settings to be removed.
[INFO] Wrote Eclipse project for "HelloWorldWebExample" to D:\workspaceMaven\Hel
loWorldWebExample.
[INFO]
Sources for some artifacts are not available.
List of artifacts without a source archive:
o jstl:jstl:1.2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.727 s
[INFO] Finished at: 2015-02-19T17:37:53+05:30
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
D:\workspaceMaven\HelloWorldWebExample>
Lets update our application code.
MyController.java
package com.javaskool.controller;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class MyController {
private static final String INDEX_PAGE = "index";
private final static org.slf4j.Logger logger = LoggerFactory.getLogger(MyController.class);
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String sayHello(ModelMap model) {
model.addAttribute("message", "Hello James Bond");
logger.debug("Hello James Bond");
// Spring uses InternalResourceViewResolver and return back index.jsp
return INDEX_PAGE;
}
}
index.jsp
<html>
<head>
<title>Maven Spring MVC Web Application</title>
</head>
<body>
<h1>Spring MVC Web Project using MAVEN Example</h1>
<h3>Message : ${message}</h3>
</body>
</html>
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Counter Web Application</display-name>
<servlet>
<servlet-name>Mymvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Mymvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Mymvc-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
Mymvc-dispatcher-servlet.xml.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.javaskool.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/view/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
logback.xml.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.javaskool.controller" level="debug" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="error">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Your updated project should looks as below.
Maven Packaging
Now, we will use Maven to compile this project and output to a “war” file. Refer to the pom.xml file, the packaging element defined what should be the packaging output.
Using Terminal through mvn package command
D:\workspaceMaven\HelloWorldWebExample>mvn eclipse:eclipse
D:\workspaceMaven\HelloWorldWebExample>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorldWebExample Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld
WebExample ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ HelloWorldWeb
Example ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ He
lloWorldWebExample ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\workspaceMaven\HelloWorldWebExampl
e\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Hello
WorldWebExample ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWorldWebExamp
le ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ HelloWorldWebExample ---
[INFO] Packaging webapp
[INFO] Assembling webapp [HelloWorldWebExample] in [D:\workspaceMaven\HelloWorld
WebExample\target\HelloWorldWebExample]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\workspaceMaven\HelloWorldWebExample\src\main
\webapp]
[INFO] Webapp assembled in [109 msecs]
[INFO] Building war: D:\workspaceMaven\HelloWorldWebExample\target\HelloWorldWeb
Example.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.623 s
[INFO] Finished at: 2015-02-19T18:44:54+05:30
[INFO] Final Memory: 7M/16M
[INFO] ------------------------------------------------------------------------
D:\workspaceMaven\HelloWorldWebExample>
Let’s Run the Application.
D:\workspaceMaven\HelloWorldWebExample\target>dir
Volume in drive D has no label.
Volume Serial Number is C601-072F
Directory of D:\workspaceMaven\HelloWorldWebExample\target
19-02-2015 18:09 <DIR> .
19-02-2015 18:09 <DIR> ..
19-02-2015 18:34 <DIR> classes
19-02-2015 18:43 <DIR> HelloWorldWebExample
19-02-2015 18:44 5,553,032 HelloWorldWebExample.war
19-02-2015 18:09 <DIR> maven-archiver
1 File(s) 5,553,032 bytes
5 Dir(s) 56,411,762,688 bytes free
D:\workspaceMaven\HelloWorldWebExample\target>
Copy this HelloWorldWebExample.war file to your tomcat webapps folder. and then check in browser as below.
Downloads Example |
Recent Comments