如何在maven pom.xml中正确定义插件版本?
我正在努力创建web应用程序,由于office惯例,我在尝试创建java web应用程序时使用了Maven/Jetty/Eclipse设置 在我的命令窗口中,我试图通过键入mvnjetty:run来编译和运行。在我得到(很可能)相关的构建失败之前,这会导致很多警告。我希望在继续之前解决这些错误,即使它们不是构建失败的原因 警告信息似乎表明我缺少插件版本的声明,我试图搜索帮助也表明了这一点。但是,我有定义的版本。我的另一个担忧是,错误表明警告(即)来自第13行。这是一条空行。我担心可能会出现一些更新问题,或者重复了pom.xml文件,但另一方面,编译器确实会对我在文件中编辑做出反应 我的错误消息是:如何在maven pom.xml中正确定义插件版本?,maven,jetty,maven-plugin,pom.xml,Maven,Jetty,Maven Plugin,Pom.xml,我正在努力创建web应用程序,由于office惯例,我在尝试创建java web应用程序时使用了Maven/Jetty/Eclipse设置 在我的命令窗口中,我试图通过键入mvnjetty:run来编译和运行。在我得到(很可能)相关的构建失败之前,这会导致很多警告。我希望在继续之前解决这些错误,即使它们不是构建失败的原因 警告信息似乎表明我缺少插件版本的声明,我试图搜索帮助也表明了这一点。但是,我有定义的版本。我的另一个担忧是,错误表明警告(即)来自第13行。这是一条空行。我担心可能会出现一些更
H:\projects\releaseplan>mvn jetty:run
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for releaseplan:releaseplan-model:jar:5
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ releaseplan:releaseplan:5, H:\projects\releaseplan\pom.xml, line 13, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ releaseplan:releaseplan:5, H:\projects\releaseplan\pom.xml, line 22, column 15
[WARNING]
[WARNING] Some problems were encountered while building the effective model for releaseplan:releaseplan-server:war:5
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ releaseplan:releaseplan:5, H:\projects\releaseplan\pom.xml, line 13, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ releaseplan:releaseplan:5, H:\projects\releaseplan\pom.xml, line 22, column 15
[WARNING]
[WARNING] Some problems were encountered while building the effective model for releaseplan:releaseplan:pom:5
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 13, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 22, column 15
以及整个pom.xml,以防错误出现在我不希望出现的地方:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>releaseplan</groupId>
<artifactId>releaseplan</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>releaseplan</name>
<build>
<plugins>
<!--<plugin> <groupId>ro.isdc.wro4j</groupId> <artifactId>wro4j-maven-plugin</artifactId>
<version>${wro4j.version}</version> <executions> <execution> <goals> <goal>jshint</goal>
</goals> </execution> </executions> <configuration> <options>devel,evil,noarg</options>
</configuration> </plugin> -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<!-- Jetty Version: 8.x Home: Eclipse, Codehaus Java Version: 1.6 Protocols:
HTTP/1.1 RFC2616, WebSocket, SPDY Servlet Version: 3.0 JSP Version: 2.1 http://wiki.eclipse.org/Jetty -->
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.13.v20130916</version>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<scanIntervalSeconds>1</scanIntervalSeconds>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>********************************************</echo>
<echo>***** This project REQUIRES Maven 3.0+ *****</echo>
<echo>********************************************</echo>
<echo>mvn jetty:run - Running as un-assembled webapp</echo>
<echo>mvn jetty:run-war - Running as assembled webapp</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<!-- <dependency> <groupId>com.dyuproject.protostuff</groupId> <artifactId>protostuff-core</artifactId>
<version>${protostuff.version}</version> </dependency> <dependency> <groupId>com.dyuproject.protostuff</groupId>
<artifactId>protostuff-json</artifactId> <version>${protostuff.version}</version>
</dependency> -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>model</module>
<module>server</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.source>1.5</compiler.source>
<compiler.target>1.5</compiler.target>
<junit.version>4.4</junit.version>
<servlet.version>2.5-20081211</servlet.version>
<jetty.version>6.1.24</jetty.version>
<protobuf.version>2.3.0</protobuf.version>
<jackson.version>1.7.9</jackson.version>
<protostuff.version>1.0.2-SNAPSHOT</protostuff.version>
</properties>
<repositories>
<repository>
<id>java</id>
<name>java</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>repo1</id>
<name>repo1</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
</project>
4.0.0
释放计划
释放计划
1.
聚甲醛
释放计划
maven编译器插件
2.3.2
1.6
1.6
jetty maven插件
8.1.13.v20130916
/
1.
maven antrun插件
初始化
跑
********************************************
*****该项目需要Maven 3.0+*****
********************************************
mvn jetty:运行-作为未组装的webapp运行
mvn jetty:运行war-作为组装的webapp运行
org.mortbay.jetty
servlet api
${servlet.version}
朱尼特
朱尼特
${junit.version}
org.codehaus.jackson
jackson core asl
${jackson.version}
模型
服务器
UTF-8
1.5
1.5
4.4
2.5-20081211
6.1.24
2.3.0
1.7.9
1.0.2-快照
JAVA
JAVA
http://download.java.net/maven/2/
报告1
报告1
http://repo1.maven.org/maven2
中心的
Maven插件库
http://repo1.maven.org/maven2
违约
假的
从未
您可能使用Maven 3,它需要知道所有插件版本,如下所述:
在父pom.xml的pluginManagement部分添加所有插件版本是正确的方法。(在企业中)最好的方法是让所有项目都使用企业父pom.xml文件
事实上,在父pom.xml属性部分添加以下行:
<maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>
3.0
并在父pom.xmlbuild>pluginManagement部分中添加以下行:
<maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>
maven编译器插件
${maven编译器plugin.version}
希望它能有所帮助……可能会有,但我必须承认,我认为我的整个设置都有缺陷。我决定把一切都记下来,从头开始。不过,这似乎是有道理的,所以我会接受答案,并留下我没有真正测试过的免责声明。