Maven 怎么装不上 环境怎么解决试了好多次

img

img

img

img

Maven 怎么装不上 环境怎么解决试了好多次 ? 到底哪里错了 ??

maven没问题,java环境有点问题,你输出一下java -verison和javac两个命令能出结果否~~

  • 帮你找了个相似的问题, 你可以看下: https://ask.csdn.net/questions/7429845
  • 这篇博客你也可以参考下:maven版本过高导致的致命无法解决错误之Maven环境搭建
  • 除此之外, 这篇博客: 要面试了?Maven相关知识都给你整理好了中的 Maven构建配置文件的类型和激活方式有哪些? 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 构建配置文件大体上有三种类型:

    类型在哪定义
    项目级(Per Project)定义在项目的POM文件pom.xml中
    用户级 (Per User)定义在Maven的设置xml文件中 (%USER_HOME%/.m2/settings.xml)
    全局(Global)定义在 Maven 全局的设置 xml 文件中 (%M2_HOME%/conf/settings.xml)

    有配置文件如下:

    <profiles>
          <profile>
              <id>test</id>
              ……
          </profile>
          <profile>
              <id>prod</id>
              ……
          </profile>
    </profiles>
    

    配置文件激活方式:

    • 使用命令控制台输入显式激活。

    mvn test -Ptest
    

    第一个 test 为 Maven 生命周期阶段,第 2 个 test 为构建配置文件指定的 id 参数,这个参数通过 -P 来传输,当然,它可以是 prod 或者 normal 这些由你定义的id

    • 通过 maven 设置。

    <settings 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/settings-1.0.0.xsd">
       ...
       <activeProfiles>
          <activeProfile>test</activeProfile>
       </activeProfiles>
    </settings>
    
    • 基于环境变量(用户或者系统变量)。 这个需要在 pom.xml 里面的 id 为 test 的 profile 节点,加入 activation 节点:

    <profiles>
          <profile>
              <id>test</id>
              <activation>
                <property>
                   <name>env</name>
                   <value>test</value>
                </property>
              </activation>
              ……
          </profile>
    </profiles>
    

    然后执行命令:

    mvn test -Denv=test
    
    • 操作系统设置(比如说,Windows系列)。 activation 元素包含下面的操作系统信息。当系统为 windows XP 时,test Profile 将会被触发。

    <profile>
       <id>test</id>
       <activation>
          <os>
             <name>Windows XP</name>
             <family>Windows</family>
             <arch>x86</arch>
             <version>5.1.2600</version>
          </os>
       </activation>
    </profile>
    

    然后执行命令:

    mvn test
    
    • 文件的存在或者缺失。 现在使用 activation 元素包含下面的操作系统信息。当 target/generated-sources/axistools/wsdl2java/com/companyname/group 缺失时,test Profile 将会被触发。

    <profile>
       <id>test</id>
       <activation>
          <file>
             <missing>target/generated-sources/axistools/wsdl2java/
             com/companyname/group</missing>
          </file>
       </activation>
    </profile>
    

    然后执行命令:

    mvn test
    
  • 您还可以看一下 崔海焘老师的Maven快速入门课程中的 Maven简介小节, 巩固相关知识点