To deploy the locally developed Maven 2 project to a Linux Tomcat step __linux

Source: Internet
Author: User
This article is a companion to the process of integrating the Maven 2 plugin into Eclipse, and describes how to deploy your MAVEN 2 project to Tomcat under Linux.
1. Configure Maven Environment variables
Configure the PATH environment variable to point to the bin directory of Maven 2. For example, my Maven 2 is installed in the D-disk tools directory, so I add a section to the environment variable path:
D:\tools\apache-maven-2.0.11\bin;
Then CommandLine input mvn-v, print out the version number of MAVEN, and other information to prove that the environment variable configuration success.
2. Add Assembly plug-in implement custom package

Modify the Pom.xml related settings as follows:[HTML] View Plain copy print? <build>       <plugins>            <plugin>       <artifactid>maven-compiler-plugin </artifactId>       <configuration>            <source>1.6</source>            <target>1.6</target>           < encoding>utf-8</encoding>           <failonerror >false</failOnError>       </configuration>   </plugin >      <plugin>       <artifactId> maven-jar-plugin</artifactid>       <configuration>           <archive>                <addMavenDescriptor>false</addMavenDescriptor>           </archive>       </ configuration>   </plugin>      <plugin>        <groupId>org.apache.maven.plugins</groupId>       < artifactid>maven-source-plugin</artifactid>       <executions>            <execution>                <id>attach-sources</id>                <phase>verify</phase>                <goals>                    <goal>jar</goal>                </goals>            </execution>       </executions>    </plugin>      <plugin>       <artifactid >maven-assembly-plugin</artifactId>       <version>2.2-beta-1</ version>       <configuration>            <descriptors>                <descriptor>assembly.xml</descriptor>            </descriptors>           <appendAssemblyId> false</appendassemblyid>       </configuration>           <executions>            <execution>               <id >make-assembly</id>                <phase>package</phase>                <goals>                    <goal>single</goal>                </goals>            </execution>       </executions>   </plugin>        </plugins>   </build>  

3.Assembly.xml Sample

Create the Assembly.xml in the same directory as Pom.xml, and edit the contents as follows:[HTML] View Plain copy print? <assembly>       <id>assembly</id>        <includeBaseDirectory>false</includeBaseDirectory>        <formats>           <format>dir</format>        </formats>       <dependencySets>            <dependencySet>                <outputdirectory>web-inf/lib</ outputdirectory>           </dependencySet>           </dependencySets>           <fileSets>           <fileSet>               <directory>./src/main/webapp</ directory>               < outputdirectory>/</outputdirectory>                <excludes>                    <exclude>*/classes/**</exclude>                    <exclude>*/lib/**</ exclude>               </excludes >           </fileSet>        </fileSets>          <files>            <file>                <source>target/${project.artifactId}-${project.version}.jar</source>                <outputdirectory>web-inf/lib</outputdirectory >           </file>        </files>         </assembly>  
4.Project Packaging
The following command line commands are executed under the root directory of the project that needs to be packaged:
MVN Package
At this point, the project root directory under the target directory will have the project name-version number. Dir folder generation, the folder has Web-inf directory, the Web-inf directory under the original project Web-inf under the various profiles, Lib can find the newly generated project name-version number. jar File and All dependent packages.
5.Directory for Linux new project Deployment
In the/home/www directory, create a new directory, preferably named after the project name, and then copy the Web-inf from step 4 to the directory.
6.Configure Tomcat

The Server.xml context tag under the Conf directory under the Tomcat root installed under Linux is modified as follows: [HTML] view plain copy print? <context docbase= "/home/www/project name" Path= "reloadable=" true "/> </Host> </Engine> </se Rvice> </Server>


7. Configure Nginx

Nginx's nginx.conf example is as follows:[Plain] View Plain copy print? user  nginx nginx ;   worker_processes  8;      Error _log  logs/error.log;   #error_log   logs/error.log  notice;   #error_log   logs/error.log  info;      #pid          logs/nginx.pid;         events {        use epoll;       worker_connections  8192;   }         http {       include        mime.types;       default_type   application/octet-stream;          log_format  main    ' [$time _local]  $remote _addr -  ' $request '   '                            ' $status   $http _user_agent '   '                            ' $args ';          access_log  logs/access.log  main;           sendfile        on;         #tcp_nopush      on;           #keepalive_timeout   0;       keepalive_timeout  120;        client_max_body_size    120m;        client_body_buffer_size 128k;       server_names_hash_bucket_size  128;      large_client_header_buffers 4 4k;       open_ file_cache max=8192 inactive=20s;       open_file_cache_min_uses 1 ;       open_file_cache_valid 30s;               gzip on;       gzip_http_version 1.0;        gzip_disable  "msie [1-6].";        gzip_min_length  1000;       gzip_ buffers     4 8k;       gzip_types        text/plain text/css application/x-javascript;          server {       listen        80;   &NBSP;&NBSP;&NBSP;&Nbsp;chunkin      on;       server_name   www.defonds.com;          charset utf-8;        access_log  logs/host.access.log  main;            #error_page   404               /404.html;          # redirect server error  pages to the static page /50x.html       #           error_page   500 502 503 504   /50x.html;       location = /50x.html {            root   html;       }        error_page 411 =  @my_411_error;       location   @my_411_error  {           chunkin_resume;        }               location = /favicon.ico {           log_not_ found off;   &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&AMP;NB

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.