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.
- Add two numbers using Java Generics
- Convert Java List to Json String using Jackson
- Convert Java Object to JSON using Jackson Library
- Java SE JDBC: Insert with PreparedStatement Example
- [Program] How to read three different values using Scanner in Java
- Java JDBC Batch Update Example with PreparedStatement
- Java Stream flatmap() Examples
- Save Java Object as JSON file using Jackson Library
- Java get day of the week as an int using DayOfWeek
- Create Nested Directories using Java Code
- Java JDBC Delete a Record in Database Table using PreparedStatement
- List of jars required for Struts2 project
- Convert Java Object to XML using Jackson Library
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Java JDBC Get Id of the Inserted Record with AutoIncrement
- How to list all tables using Java JDBC
- Java Jackson ObjectMapper Class with Examples
- Fix: Maven - Failed to execute goal - Compilation failure - Source/Target option 5 is no longer supported. Use 7 or later
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Formatting Double in Java [Examples]
- How to run Java Unit Test cases with Apache Maven?
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- [Fix] java: integer number too large compilation error
- [Java] Read a File with UTF-8 Encoding
- How to detect Operating System using Java code
- Splitting String in Java with Examples - Java
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ - Java
- How to remove/delete a directory in Linux/macOs - Linux
- Fix: Cannot contact reCAPTCHA. Check your connection and try again. - Google
- Android Constant and Resource Type Mismatches Lint - Android
- Microsoft Teams - Where would you like to start - Business or Personal - Teams
- How to add Date and Time to Windows Notepad File - NotepadPlusPlus
- [Fix] java: incompatible types: incompatible parameter types in lambda expression error - Java