<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>com.wang</groupId>
<artifactId>test-maven-server-console</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test-maven-server-console</name>
<packaging>war</packaging>
<properties>
<warPackageName>MyWebAppDemo</warPackageName>
<tomcat.server>tomcat</tomcat.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!--
<dependency>
<groupId>com.wang</groupId>
<artifactId>test-maven-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
--> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.6.RELEASE</version>
</dependency> <dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency> <dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency> <dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
</dependencies> <build>
<finalName>${warPackageName}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<version>2.5</version>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<!-- <warFile>target/serverdemo.war</warFile> -->
<server>${tomcat.server}</server>
<url>http://192.168.234.9:8080/manager/text</url>
<path>/${warPackageName}</path>
</configuration>
</plugin>
</plugins>
</build> </project>

1、build

Server:用来指定到哪个服务器,${}获取properties中的变量tomcat,然后调用settings.xml文件中配置的tomcat和用户名、密码(上一节)

url:用来指定发布到服务器的地址,h后面必须跟text

path:即部署到服务器的项目名,这里是webapps/MyWebAppDemo.war.访问路径http://192.168.234.9:8080/MyWebAppDemo

profile:

Server变量有三种配置方式:

a、

<properties>
<warPackageName>MyWebAppDemo</warPackageName>
<tomcat.deploy.server>localTestServer</tomcat.deploy.server>
<tomcat.deploy.serverUrl>http://localhost/manager/text</tomcat.deploy.serverUrl>
</properties>

b、

<profiles>
<profile>
<id>deploy2production</id>
<properties>
<tomcat.deploy.server>productionServer</tomcat.deploy.server>
<tomcat.deploy.serverUrl>http://120.26.93.30:8080/manager/text</tomcat.deploy.serverUrl>
</properties>
</profile>
</profiles>

c、

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>8089</port>
<path>/</path>
<url>http://192.168.234.9:8080/manager/text</url>
<username>admin</username>
<password>admin</password>
<update>true</update>
</configuration>
</plugin>

2、UTF-8编码问题

3、Spring框架冲突问题

因为既依赖dubbo框架,又依赖spring框架,导致报错(一般报NoSuchMethodError都是因为依赖冲突)

22-Oct-2016 01:17:46.438 信息 [http-nio-8080-exec-11] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
22-Oct-2016 01:17:46.550 严重 [http-nio-8080-exec-11] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createConcurrentMapIfPossible(I)Ljava/util/Map;

解决方法:

 <dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>

4、web.xml问题

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project test-maven-server-console: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

解决方法:手动配置读取web.xml

<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<version>2.5</version>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>

5、Maven clean导致引入jar文件没有编译的问题

[ERROR] /F:/stsProjects/test-maven-server-console/src/main/java/com/test/dubbo/controller/IndexController.java:[8,39] 程序包com.test.dubbo.registry.service不存在

[ERROR] /F:/stsProjects/test-maven-server-console/src/main/java/com/test/dubbo/controller/IndexController.java:[14,17] 找不到符号

符号:   类 TestRegistryService

位置: 类 com.test.dubbo.controller.IndexController

6、Maven默认使用jdk1.5的问题

7、web项目不存在src/main/webapp目录的问题

右键项目—Build Path -- Configure Build Path –Libraries –双击JRE System Liaraies – 在Execution environment选择合适版本

完整的项目目录:

结合实际项目分析pom.xml的更多相关文章

  1. spring maven pom.xml设置

    spring pom.xml设置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns= ...

  2. Maven实战:pom.xml与settings.xml

    pom.xml与settings.xml pom.xml与setting.xml,可以说是Maven中最重要的两个配置文件,决定了Maven的核心功能,虽然之前的文章零零碎碎有提到过pom.xml和s ...

  3. 批量从jar包中提取pom.xml

    将非maven项目转换为maven项目,首要第一步就是提取原工程依赖jar里的pom.xml,拼成<dependency>节点 import java.io.File; import ja ...

  4. Maven的POM.xml配置大全

    <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://mave ...

  5. Maven pom.xml 元素配置说明(一)

    部分来源: Maven中 dependencies 节点和 dependencyManagement 节点的区别 dependencies与dependencyManagement的区别 maven ...

  6. 史上最全的maven的pom.xml文件详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  7. 【maven】pom.xml报错:Cannot detect Web Project version.

    新建的maven项目 报错如下: Cannot detect Web Project version. Please specify version of Web Project through &l ...

  8. Maven的pom.xml 配置详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. (六)Maven之pom.xml文件简单说明

    通过前面几部分知识,我们对maven已经有了初步的印象,就像Make的Makefile.Ant的build.xml一样,Maven项目的核心是pom.xml.POM(Project Object Mo ...

随机推荐

  1. HDU 3594 Cactus (强连通分量 + 一个边只能在一个环里)

    题意:判断题目中给出的图是否符合两个条件.1 这图只有一个强连通分量 2 一条边只能出现在一个环里. 思路:条件1的满足只需要tarjan算法正常求强连通分量即可,关键是第二个条件,我们把对边的判断转 ...

  2. Base64笔记

    1. 昨天的<MIME笔记>中提到,MIME主要使用两种编码转换方式----Quoted-printable和Base64----将8位的非英语字符转化为7位的ASCII字符. 虽然这样的 ...

  3. 快速部署Python应用:Nginx+uWSGI配置详解

    在PHP里,最方便的就是deployment了,只要把php文件丢到支持PHP的路径里面,然后访问那个路径就能使用了:无论给主机添加多少PHP应用,只要把目录改好就没你的事了,完全不用关心php-cg ...

  4. HTML5来了:5个好用的混合式App开发工具

    在残酷的移动互联网竞争环境下, HTML5技术一直受到各方关注,“HTML5颠覆原生 App”的争论也从未停止过,不管怎样HTML5生态的构建方兴未艾.不过对于移动开发者来说更关心的问题是如何低成本. ...

  5. 剑指offer 重建二叉树

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  6. HDU 5875 st+二分区间

    题目大意:给你n个数,q次询问,每次询问区间[l, r],问a[i]%a[i + 1] % a[i + 2]...%a[j](j <= r)的值 思路:st预处理维护,再二分区间,复杂度n*(l ...

  7. zf-关于注册码全部错误的解决方法

    之所以错误,是因为这里的用户名称是石首市政务服务中心. 在数据库里把这个字段改成 上海卓繁 就可以了 一般都是在 SYS_INFO 这张表里面改

  8. 关于tomcat 成功运行之后内存泄露

    在window-preferences  里 搜索 tomcat-jdk 加上以下内容即可 -Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize= ...

  9. jQuery获取Select选中的Text和Value,根据Value值动态添加属性等

    语法解释:1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发2. var ch ...

  10. Gerald and Giant Chess

    Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input stand ...