Intellij idea community edition & amp; maven & amp; git & amp; tomcat/jetty's struts2 project establishment, intellijidea community

Source: Internet
Author: User

Intellij idea community edition & maven & git & tomcat/jetty's struts2 project establishment, intellijidea community

1. Create a project and create a maven module under the project.

1.1 check Create from archetype, select maven-archetype-webapp, enter ArtifactId and module, and finish;

1.2 maven automatically downloads the required jar package and constructs the following directory structure:

Module name

-- Src

-- Main

-- Resources

-- Webapp

WEB-INF

-- Web. xml

-- Index. jsp

-- Pom. xml

1.3 if you do not know why the java folder is not generated, manually add it under main. After adding the folder, right-click and choose Make Directory As -- Sources Root.

 

2 add struts2

2.1 Add the struts2 dependency to pom. xml:

<! -- Struts2 dependency package --> <dependency> <groupId> org. apache. struts </groupId> <artifactId> struts2-core </artifactId> <version> 2.3.14 </version> </dependency>

2.2 Add filter and mapping to web. xml

  <filter>    <filter-name>struts2</filter-name>    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter>  <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>

2.3 add struts2.xml in resources and configure the corresponding Action

 

3. Add an Application Server

3.1 add jetty and add jetty plugin the pom. xml file

<plugin>    <groupId>org.mortbay.jetty</groupId>    <artifactId>maven-jetty-plugin</artifactId>    <version>6.1.10</version>    <configuration>          <scanIntervalSeconds>10</scanIntervalSeconds>          <stopKey>foo</stopKey>          <stopPort>9999</stopPort>     </configuration>     <executions>            <execution>                    <id>start-jetty</id>                    <phase>pre-integration-test</phase>                    <goals>                          <goal>run</goal>                     </goals>                     <configuration>                            <scanIntervalSeconds>0</scanIntervalSeconds>                            <daemon>true</daemon>                      </configuration>             </execution>             <execution>                      <id>stop-jetty</id>                      <phase>post-integration-test</phase>                      <goals>                            <goal>stop</goal>                       </goals>             </execution>      </executions></plugin> 

3.2 or add tomcat. Select tomcat7

            <plugin>                <groupId>org.apache.tomcat.maven</groupId>                <artifactId>tomcat7-maven-plugin</artifactId>                <version>2.1</version>                <configuration>                    <port>9090</port>                    <path>/t1</path>                    <uriEncoding>UTF-8</uriEncoding>                    <finalName>t1</finalName>                    <server>tomcat7</server>                </configuration>            </plugin>        

 

4. Add version control git

4.1 click the IntelliJ idea tool bar vcs and select Import into Version Control -- Create Git Repository

4.2 select the module folder, OK

4.3 Add the. gitignore file to the module root directory and set git to ignore. idea and other files.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.