这里假设Java11和maven都正确安装,使用的版本为Java11、maven3.6.1

测试环境变量

Java

win + r 打开运行,输入 cmd,打开命令行提示符,输入java --version如下

C:\Users\siyu>java --version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Maven

win + r 打开运行,输入 cmd,打开命令行提示符,输入mvn -v如下

C:\Users\siyu>mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: D:\Program Files (x86)\Maven\apache-maven-3.6.1\bin\..
Java version: 11.0.2, vendor: Oracle Corporation, runtime: D:\Program Files (x86)\openjdk\jdk-11
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Maven 镜像配置

因 Maven 默认镜像在国内下载限制,因此,建议更改为阿里云的镜像,方法如下:(建议修改 settings.xml 前先复制保持一份)

打开文件对应安装目录的settings.xml文件,例如我的目录是D:\Program Files (x86)\Maven\apache-maven-3.6.1\confsettings.xml,编辑为如下:

<?xml version="1.0" encoding="UTF-8"?>
...省略
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:\ProgramData\MavenRepo</localRepository> <!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
--> <!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
--> <!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups> <!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies> <!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
--> <!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers> <!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
--> <mirror>
<id>huaweicloud</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.huaweicloud.com/repository/maven/</url>
</mirror>
</mirrors> ...省略 <profiles>
...省略
<profile>
<id>env-dev</id> <activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation> <properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
<profile>
<id>jdk-11</id> <activation>
<activeByDefault>true</activeByDefault>
<jdk>11</jdk>
</activation>
<!--
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
</properties> -->
</profile> </profiles>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>

解释

添加了本地仓库和国内镜像源

关联问题:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)

参考来源

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)

Java11配置maven的更多相关文章

  1. eclipse内下载及配置maven插件(转)

    本文介绍Maven的安装和配置,同样适用于eclipse 1.首先需要安装jdk,eclipse(废话!). 然后到maven官网下载maven,http://maven.apache.org/dow ...

  2. myeclipse配置maven

    1.首先配置好java的运行环境(JDK要1.7及以上版本),网上有详细资料. 2.下载maven,具体下载链接http://maven.apache.org/download.html 3.下载ap ...

  3. Java 配置maven及阿里云镜像

    一:配置maven 1.下载maven,选择Binary tar.gz,解压拷贝到目录/usr/local/ https://maven.apache.org/download.cgi 2.配置系统默 ...

  4. 使用IntelliJ IDEA 配置Maven(入门)【转】

    1.在IntelliJ IDEA中配置maven 打开-File-Settings  2.新建maven WEB项目 打开-File-New-Project 点击NEXT  点击NEXT  添加的配置 ...

  5. 使用IntelliJ IDEA 配置Maven(入门)

    1. 下载Maven 官方地址:http://maven.apache.org/download.cgi 解压并新建一个本地仓库文件夹 2.配置本地仓库路径   3.配置maven环境变量      ...

  6. 使用IntelliJ IDEA 配置Maven(入门)(转)

    原文转自:http://blog.csdn.net/qq_32588349/article/details/51461182 1. 下载Maven 官方地址:http://maven.apache.o ...

  7. idea配置maven并添加镜像配置

    1.打开maven存放文件夹找到 conf ->settings.xml 找到<mirrors>节点把下面内容写入节点内 配置为阿里云的镜像 <mirror> <i ...

  8. [转]maven安装以及eclipse配置maven

    转自:http://jingyan.baidu.com/article/295430f136e8e00c7e0050b9.html 方法/步骤 下载maven的bin,在apache官方网站可以下载. ...

  9. Maven学习(一) -- 安装Maven及Eclipse中配置Maven

    标签(空格分隔): 学习笔记 本文环境:Windows7, JDK1.7.0_76 安装及配置Maven环境变量 需要电脑中已经有Java环境 在控制台中输入:echo %JAVA_HOME%看是否能 ...

  10. Eclipse 配置Maven

    Eclipse 配置Maven 下载Maven 首先在官网下载Maven:http://maven.apache.org/download.cgi 下载后将其解压到相应的位置 配置Maven环境变量 ...

随机推荐

  1. 如何使用libavfilter库给pcm音频采样数据添加音频滤镜?

    一.初始化音频滤镜 初始化音频滤镜的方法基本上和初始化视频滤镜的方法相同,不懂的可以看上篇博客,这里直接给出代码: //audio_filter_core.cpp #define INPUT_SAMP ...

  2. 一文了解 io.LimitedReader类型

    1. 引言 io.LimitedReader 提供了一个有限的读取功能,能够手动设置最多从数据源最多读取的字节数.本文我们将从 io.LimitedReader 的基本定义出发,讲述其基本使用和实现原 ...

  3. 通过ssh远程执行kubectl命令报错问题

    在使用Jenkins链接Kubernetes集群,如果Jenkins安装机器与Kubernetes Master节点不在同一台机器上面,需要使用ssh远程执行部署命令,如下: ssh root@10. ...

  4. java后台导出表格文件

    Java类所需jar包 import java.io.File; import java.io.IOException; import java.io.InputStream; import java ...

  5. 【MAUI Blazor踩坑日记】3.Windows标题栏自定义颜色,运行时改变颜色

    目录 修改默认颜色 修改运行时颜色 效果图 MAUI中Windows默认的标题栏颜色是灰色的,有一点丑. 如果去掉默认的标题栏,自己画一个,可能会出现问题,也比较麻烦. 想要自定义默认标题栏的颜色,官 ...

  6. 与AI对话 -- 20230221 -- linux 性能分析相关的软件包

    linux 性能分析相关的软件包有哪些,各自包含了哪些命令 sysstat:sysstat 包含了丰富的监控系统性能的工具,例如 sar(系统性能分析器).iostat(设备 IO 状态分析器).mp ...

  7. openpyxl 设置某列单元格样式

    1 # 边框线 2 border_set = Border(left=Side(border_style='thin', color='000000'), 3 right=Side(border_st ...

  8. PHP插件

  9. python入门,一篇就够了

    python规范 函数必须写注释:文档注释格式'''注释内容''' 参数中的等号两边不要用空格 相邻函数用两个空行隔开 小写 + 下划线 函数名 模块名 实例名 驼峰法 类名 tips # 一行代码太 ...

  10. ABC295 D题 题解

    题意简述 给定一个长度不超过\(\;5\times 10^5\;\)的,仅有数字构成的字符串,问存在多少段子串,使得子串内字符重新排序后,前半段与后半段相同? 做法分析 重组后前后两部分相同,其实也就 ...