解决eclipse+MAVEN提示One or more constraints have not been satisfied.的问题

应用版本:eclipse luna4.4.1

JDK:1.8

Maven:3.2.5

问题现象:

1、编译工程后总该是显示下面两个错误:

  One or more constraints have not been satisfied.

      Deployment Assembly跟java版本不匹配

 

解决方案:

在pom.xml中添加下面内容即可,同时也可以解决Maven->update project默认jdk的问题

复制代码

<profiles>
    <profile>
        <id>jdk-1.8</id>
        <!-- 另外一种激活方式 -->
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>
</prof

复制代码

2、使用Eclipse自动Maven插件更新jar包失败(Nexus仓库配置都正常),提示如下错误:
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building  0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.148 s
[INFO] Finished at: 2014-12-30T17:38:07+08:00
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-resources-plugin:jar:2.6 in http://localhost:8082/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
 huige 18:06:21
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.

......

解决方案:

更新Maven包到最新版本即可(JDK1.8+Eclipse luna4.4.1搭配建议更新Maven到3.2.5版本之后)

preferences-》Maven-》Installations 选择最新的Maven地址

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我会尽可能详细地回答你的问题。 首先,我们需要了解一下这几个工具的作用: - Eclipse:Java开发的集成开发环境(IDE) - Maven:Java项目管理工具,可以自动化构建、依赖管理、打包等操作 - Junit5:Java的单元测试框架,可以方便地编写和执行单元测试 - Pitest:Java的变异测试框架,可以自动生成变异体并运行测试用例,用于评估测试用例的质量。 接下来,我们按照以下步骤来进行参数化测试: 1. 在 Eclipse 中创建 Maven 项目,可以选择使用 Maven 的 Quickstart 模板来创建。 2. 在 pom.xml 文件中添加 Junit5 和 Pitest 的依赖: ```xml <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.7.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.pitest</groupId> <artifactId>pitest-junit5-plugin</artifactId> <version>0.13</version> </dependency> ``` 3. 编写测试类,使用 Junit5 的 ParameterizedTest 注解来标记参数化测试方法,并使用 ValueSource 注解来指定参数值: ```java import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; class CalculatorTest { private final Calculator calculator = new Calculator(); @ParameterizedTest @ValueSource(ints = {1, 2, 3}) void testAdd(int value) { int result = calculator.add(value, 2); Assertions.assertEquals(value + 2, result); } } ``` 4. 运行测试,可以使用 Maven 命令 `mvn test` 来执行所有测试用例,也可以使用 Eclipse 的 Junit5 运行器来执行单个测试用例。 5. 运行 Pitest,可以使用 Maven 命令 `mvn org.pitest:pitest-maven:mutationCoverage` 来运行 Pitest。Pitest 会自动生成变异体并运行测试用例,最后生成一个变异测试报告。 以上就是使用 Eclipse+Maven+Junit5+Pitest 进行参数化测试的步骤。希望对你有所帮助!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值