本文主要是介绍解决maven打包Mark invalid异常,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
[size=large]今天在用maven打包spring-boot项目时,报了如下的一个异常:[/size][ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project sea
rch-zk-increment-monitor: Mark invalid -> [Help 1]
[size=large]pom文件如下:[/size]
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.antrust</groupId>
<artifactId>search-zk-increment-monitor</artifactId>
<version>1.0.0-SNAPSHOT</version>
<!--父依赖-->
<parent>
<groupId>cn.bizbook.product</groupId>
<artifactId>any-products-bizbook-parent</artifactId>
<version>1.1.2</version>
</parent>
<!--管理多parant问题-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>1.2.5.RELEASE</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!--指定编码-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--zk的版本号-->
<zookeeper.version>3.4.6</zookeeper.version>
<!--curator版本号-->
<curator-client.version>2.8.0</curator-client.version>
<!--commons-io版本号-->
<commons-io.version>2.4</commons-io.version>
<!--gson版本号-->
<gson.version>2.3.1</gson.version>
<!--lucene-solr的版本号-->
<lucene-solr.version>5.1.0</lucene-solr.version>
<!--httpclient的版本号-->
<httpclient.version>4.3.1</httpclient.version>
</properties>
<build>
<!--指定下面的目录为资源文件-->
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<!--设置自动替换-->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<!--也可以用排除标签-->
<!--<excludes></excludes>-->
<!--开启过滤-->
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!--
比较常用的打包命令
mvn clean package spring-boot:repackage
只有使用下面的maven命令在cmd窗口启动,
热加载才能生效,如果直接Run运行的Application是
不支持热加载的
mvn clean spring-boot:run
-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.2.2.RELEASE</version>
<dependencies>
<!--引入springloaded来实现动态加载-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
<configuration>
<!-- <mainClass>com.dhgate.rate.ApplicationSearch</mainClass> -->
<!--指定监听的端口号-->
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777
</jvmArguments>
</configuration>
</plugin>
<!-- 下面此插件解决filter
resources下有这行代码异常
<filtering>true</filtering>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<!-- any-bizbook-common(with dubbo and base spring conf) -->
<dependency>
<groupId>cn.bizbook.product</groupId>
<artifactId>any-products-bizbook-common</artifactId>
<version>0.0.2</version>
<scope>compile</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-web</artifactId>-->
<!--</dependency>-->
<!--web容器支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--web容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.eclipse.jetty.websocket</groupId>-->
<!--<artifactId>*</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
</dependency>
<!--jedis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<!--操作Zookeeper的框架-->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
<version>${curator-client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator-client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator-client.version}</version>
</dependency>
<!-- Spring test类 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!-- 性能监控 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 安全验证 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--Velocity引擎的支持,如果你需要其他的模板引擎,则-->
<!--可以直接引入其他的即可-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!--Gson支持-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<!--Hbase服务化api接口-->
<dependency>
<groupId>cn.bizbook.product</groupId>
<artifactId>any-products-bizbook-record-api</artifactId>
<version>1.1.0-SANPSHOT</version>
</dependency>
<!--solrj核心依赖 -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>${lucene-solr.version}</version>
<exclusions>
<exclusion>
<artifactId>spatial4j</artifactId>
<groupId>com.spatial4j</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-annotations</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-auth</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-common</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-hdfs</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-suggest</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-spatial</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-queries</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-misc</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-memory</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-join</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-highlighter</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-grouping</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-expressions</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-codecs</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-backward-codecs</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-analyzers-phonetic</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
<exclusion>
<artifactId>lucene-analyzers-kuromoji</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
</exclusions>
</dependency>
<!--Solrj客户端 -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>${lucene-solr.version}</version>
</dependency>
<!--solrj的httpclient依赖 -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
</dependencies>
<profiles>
<!--默认激活开发配置,使用index-dev.properties来替换实际的文件key-->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/filters/any-dev.properties</filter>
</filters>
</build>
</profile>
<!-- 测试环境配置 -->
<profile>
<id>test</id>
<build>
<filters>
<filter>src/main/filters/any-test.properties</filter>
</filters>
</build>
</profile>
<!-- 生产环境配置 -->
<profile>
<id>product</id>
<build>
<filters>
<filter>src/main/filters/any-product.properties</filter>
</filters>
</build>
</profile>
</profiles>
</project>
[size=large]
经查阅stackoverflow的资料,发现应该算是maven filter resource的一个bug, 如
何解决? 在pom文件里面加入,如下的一个filter依赖,即可:
[/size]
<!-- 下面此插件解决filter
resources下有这行代码异常
<filtering>true</filtering>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
[size=large]参考资料:
[url]http://stackoverflow.com/questions/26281322/mavenfailed-to-execute-goal-org-apache-maven-pluginsmaven-resources-plugin2-7[/url][/size]
这篇关于解决maven打包Mark invalid异常的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!