Let's see how we can create a very simple project structure for Struts2 application using maven in command prompt or terminal.
Note: Below is an example demonstrated on Mac OS X using terminal
Lets first set the JAVA_HOME and PATH for maven ( my version is maven 3.3.3)
localhost:~ code2care$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/
localhost:~ code2care$ export PATH=/Users/code2care/Setups/apache-maven-3.3.3/bin:$PATH
Now let's run the maven archetype: generate a command to display the project stub :
localhost:~ code2care$ mvn archetype:generate
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
9: remote -> br.com.address.archetypes:struts2-archetype (an archetype web 3.0 + struts2 (bootstrap + jquery) + JPA 2.1 with struts2 login system)
167: remote -> com.jgeppert.struts2.jquery:struts2-jquery-archetype-base (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Plugin.)
168: remote -> com.jgeppert.struts2.jquery:struts2-jquery-archetype-mobile (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Mobile Plugin.)
169: remote -> com.jgeppert.struts2.jquery:struts2-jquery-bootstrap-archetype-grid (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Grid Plugin and the Struts2
743: remote -> org.apache.struts:struts2-archetype-angularjs (-)
744: remote -> org.apache.struts:struts2-archetype-blank (-)
745: remote -> org.apache.struts:struts2-archetype-convention (-)
746: remote -> org.apache.struts:struts2-archetype-dbportlet (-)
747: remote -> org.apache.struts:struts2-archetype-plugin (-)
748: remote -> org.apache.struts:struts2-archetype-portlet (-)
749: remote -> org.apache.struts:struts2-archetype-starter (-)
I have just listed out a few struts2 projects that may be useful for us
Lets select number 744 : org.apache.struts:struts2-archetype-blank
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 644: 744
Select the struts 2 version that you want : I have selected 25 i.e. version 2.3.24
Choose org.apache.struts:struts2-archetype-blank version:
1: 2.2.1
2: 2.2.1.1
3: 2.2.3
4: 2.2.3.1
5: 2.3.3
6: 2.3.4
7: 2.3.4.1
8: 2.3.7
9: 2.3.8
10: 2.3.12
11: 2.3.14
12: 2.3.14.1
13: 2.3.14.2
14: 2.3.14.3
15: 2.3.15
16: 2.3.15.1
17: 2.3.15.2
18: 2.3.15.3
19: 2.3.16
20: 2.3.16.1
21: 2.3.16.2
22: 2.3.16.3
23: 2.3.20
24: 2.3.20.1
25: 2.3.24
26: 2.5-BETA1
Choose a number: 26: 25
Downloading: https://repo.maven.apache.org/maven2/org/apache/struts/struts2-archetype-blank/2.3.24/struts2-archetype-blank-2.3.24.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/struts/struts2-archetype-blank/2.3.24/struts2-archetype-blank-2.3.24.jar (39 KB at 13.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/struts/struts2-archetype-blank/2.3.24/struts2-archetype-blank-2.3.24.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/struts/struts2-archetype-blank/2.3.24/struts2-archetype-blank-2.3.24.pom (3 KB at 4.0 KB/sec)
Define the properties : groupId, artifactId, version and package,
Define value for property 'groupId': : org.code2care.struts2
Define value for property 'artifactId': : HelloStruts2
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.code2care.struts2: :
Confirm properties configuration:
groupId: org.code2care.struts2
artifactId: HelloStruts2
version: 1.0-SNAPSHOT
package: org.code2care.struts2
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: struts2-archetype-blank:2.3.24
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.code2care.struts2
[INFO] Parameter: artifactId, Value: HelloStruts2
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.code2care.struts2
[INFO] Parameter: packageInPathFormat, Value: org/code2care/struts2
[INFO] Parameter: package, Value: org.code2care.struts2
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.code2care.struts2
[INFO] Parameter: artifactId, Value: HelloStruts2
[INFO] project created from Archetype in dir: /Users/code2care/HelloStruts2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:37 min
[INFO] Finished at: 2015-09-15T11:47:15+05:30
[INFO] Final Memory: 13M/98M
[INFO] ------------------------------------------------------------------------
localhost:~ code2care$
That's it! You should see BUILD SUCCESS and the location where the project HelloStruts2 just above that info line.
- Java XML-RPC 3.1.x based web service example
- List of jars required for Struts2 project
- list of jars required for hibernate 4.x.x
- How to create StackOverflow error in java
- Tutorial Java SOAP WebServices JAS-WS with Eclipse J2EE IDE and Tomcat Server Part 1
- import servlet API to eclipse project (javax.servlet cannot be resolved error)
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- Convert String to int in Java
- JSP Hello World Program Tutorial with Eclipse and Tomcat Server
- SharePoint Open in the client application document opens in browser
- Java: TimeZone List with GMT/UTC Offset
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Remove Trailing zeros BigDecimal Java
- [Solution] Java Error Code 1603. Java Update did not complete.
- Maven Eclipse (M2e) No archetypes currently available
- error: file not found: HelloWorld.java
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to check if Java main thread is alive
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated
- Java XML-RPC java.net.BindException: Address already in use
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- List of jar files for Jax-ws (SOAP) based Java Web Services
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- Maven Unsupported major.minor version 51.0
- hibernate.cfg.xml Configuration and Mapping xml Example
- How to verify if java is installed on the computer and get version detail
- Unhandled exception type InterruptedException : Java Threads
- XmlRpcException ConnectException connection refused error
- Error: Unable to access jarfile jarFileName.jar file [Windows]
- BeanDefinitionStoreException IOException parsing XML document from class path resource [spring.xml]
- How to serialize-deserialize an object in java
- List of Java Keywords
- Simple Struts 2 Tutorial in eclipse with tomcat 7 server
- Struts 2 Hello World Example in Eclipse
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- List of Java versions
- Create simple struts2 project using maven commands
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- Error: Can not find the tag library descriptor for
- connection.url property value in hibernate.cfg.xml for mysql
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Setting Java_Home Environment variable on Windows Operating System
- Unable to load VM from snapshot. The snapshot has been saved for a different hardware configuration - Android
- Get Wifi Details : Android Programming - Android
- JSON Syntax : JSON Tutorial - Json-Tutorial
- Word count in Notepad++ - NotepadPlusPlus
- SharePoint Server 2016 error - Failed to connect to the configuration database - SharePoint
- Android Alert Dialog with Checkboxes example - Android
- java.lang.NoClassDefFoundError android.support.v4.content.LocalBroadcastManager - Android
- [Notepad++] Remove CR Carriage Return and LF Line feed (CRLF) - NotepadPlusPlus
- Failed to install Android.apk on device 'emulator-5554': timeout - Android-Studio
- How to get Mobile Screen Resolution Width and Height programatically - Android
- Tomcat Manager Default Username and Password - Tomcat
- Turning Off Chat in Gmail - Google
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion - SharePoint
- Find Sum of two numbers - C-Program
- Struts 2 Hello World Example in Eclipse - Java