How to deploy WAR with Maven to Tomcat? -


i use maven eclipse. possible build project , deploy built war file tomcat server?

i use windows. can build war file, , deploy on server manually. want deploy war file automatically after build action , doesn't work. novice in maven.

should set in run configuration? have set goals install value.

pom.xml

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>helloworld</groupid> <artifactid>helloworld</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <name>helloworld</name>  <properties>     <spring.version>3.2.2.release</spring.version> </properties>  <dependencies>      <!-- java server pages standard tag library -->     <dependency>         <groupid>jstl</groupid>         <artifactid>jstl</artifactid>         <version>1.2</version>     </dependency>       <!-- spring 3 dependencies -->     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-core</artifactid>         <version>${spring.version}</version>     </dependency>      <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-beans</artifactid>         <version>${spring.version}</version>     </dependency>      <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-context</artifactid>         <version>${spring.version}</version>     </dependency>      <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-web</artifactid>         <version>${spring.version}</version>     </dependency>      <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-webmvc</artifactid>         <version>${spring.version}</version>     </dependency> </dependencies>  <build>     <directory>${project.basedir}/target</directory>     <plugins>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-compiler-plugin</artifactid>             <version>2.3.2</version>             <configuration>                 <source>${java-version}</source>                 <target>${java-version}</target>             </configuration>         </plugin>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-dependency-plugin</artifactid>             <executions>                 <execution>                     <id>install</id>                     <phase>install</phase>                     <goals>                         <goal>sources</goal>                     </goals>                 </execution>             </executions>         </plugin>         <!-- maven tomcat plugin -->         <plugin>             <groupid>org.codehaus.mojo</groupid>             <artifactid>tomcat-maven-plugin</artifactid>             <configuration>                 <server>apache_tomcat_7_x86</server>                 <warfile>${project.build.directory}/helloworld-0.0.1-snapshot.war</warfile>             </configuration>         </plugin>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-war-plugin</artifactid>             <version>2.3</version>             <configuration>                 <packagingexcludes>web-inf/web.xml</packagingexcludes>             </configuration>         </plugin>     </plugins> </build> 

furthermore changed settings.xml file in path ~/.m2/settings.xml.

settings.xml

  <servers>       <server>         <id>apache_tomcat_7_x86</id>         <username>admin</username>         <password>admin</password>       </server>   </servers> 

meanwhile resolved it. there few issues.

firstly set goal in eclipse run configuration tomcat:deploy.

and changed pom.xml following

<plugin>   <groupid>org.codehaus.mojo</groupid>   <artifactid>tomcat-maven-plugin</artifactid>   <configuration>     <url>http://localhost:8080/manager/text</url>     <server>apache_tomcat_7_x86</server>     <path>/helloworld</path>   </configuration> </plugin> 

url in configuration depends on tomcat version. me works text, others works html on end of url. , of course, in tomcat-users.xml must set role manager-script or manager-gui.

maybe helps others.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -