解决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]
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
对于 Maven 打包过程中出现的 "找不到符号" 错误,可能有多种原因和解决办法。以下是一些常见的解决办法: 1. 依赖未正确导入:请确保你的 pom.xml 文件中的依赖项正确导入,并且使用的版本号是有效的。你可以尝试运行 `mvn clean install` 命令清理并重新安装依赖。 2. 依赖冲突:如果你的项目中存在多个版本的相同依赖,可能会导致找不到符号的错误。在 pom.xml 文件中检查依赖项,并解决任何冲突。 3. 编译错误:如果你的代码中存在编译错误,可能会导致找不到符号的错误。请确保你的代码没有语法错误,并尝试修复任何编译错误。 4. 重新生成项目:有时候项目文件可能会损坏,导致编译错误。你可以尝试删除目标文件夹(一般是 target 文件夹)并重新生成项目。 5. 检查类路径:确保你的项目配置正确,并且类路径正确设置。你可以检查 pom.xml 文件或 IDE 中的构建路径设置。 6. 检查依赖库:如果你使用了自定义的依赖库,可能需要手动将其导入到项目中。确保库文件存在,并正确配置在构建路径中。 7. 更新 Maven 插件:如果你使用的是旧版的 Maven 插件,可能会导致一些问题。请尝试更新 Maven 插件到最新版本,并重新构建项目。 如果以上方法仍然不能解决问题,建议提供更多的错误信息和项目配置细节,以便更具体地帮助你解决问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值