简体   繁体   中英

How to get the path of maven settings.xml programmatically

有没有办法从默认系统属性或maven选项中获取Java程序中maven settings.xml文件的路径。我想避免通过配置文件从用户那里获取该信息。

As per the maven documentation ,

There are two locations where a settings.xml file may live:

  • The Maven install: ${maven.home}/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml

To access maven.home

System.getenv("M2_HOME");

To access user.home

System.getProperty("user.home");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM