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.
- Convert Java Map Collection Object to JSON String using Jackson
- Java Stream flatmap() Examples
- [Fix] Instant java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Years
- How to run Java Unit Test cases with Apache Maven?
- How to check if Java main thread is alive
- [Fix] java: incompatible types: incompatible parameter types in lambda expression error
- Parsing CSV file using Java code example (Comma Separated File)
- Unhandled exception type InterruptedException : Java Threads
- Native getClass() method from java.lang.Object Class Explained with examples.
- Java Jackson ObjectMapper Class with Examples
- Java 8 Streams map() with examples
- Java 8 - Convert List to Map Examples
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- Java Stream with Multiple Filters Example
- How to Clear StringJoiner in Java 8
- Spring 5 IoC Example with application Context XML (ClassPathXmlApplicationContext) and Gradle.
- How to get end of line (EOL) or new line character \r \n in Java
- Spring Boot CRUD Examples using JDBCTemplate
- Delete a File in Java with Examples
- Implementing Insertion Sort Algorithm in Java Program
- Java JDBC Batch Update Example with PreparedStatement
- Java JDBC Select Multiple Records from table as List using PreparedStatement
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated
- How to fix Java HTTP java.net.UnknownHostException
- Java 8 Display time in 12 hour AM PM format
- apt-get list --installed packages in Ubuntu Linux - Ubuntu
- How to get unique values from a list in Python - Python
- SQL: Check if table exists - HowTos
- What is $$ in Bash Shell Script- Special Variable - Bash
- Open New tab using keyboard shortcut in Mac Terminal - Mac-OS-X
- W3 HTML validator warning Unable to Determine Parse Mode - Html
- Show Hidden Files in Mac Terminal - MacOS
- Disable Fading Edges Scroll Effect Android Views - Android