展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

属性

  • 自定义属性
# 父工程
<properties>
    <spring.version>5.1.9.RELEASE</spring.version>
    <junit.version>4.12</junit.version>
</properties>

<dependencyManagement>
    <dependencies>
        <!--spring环境-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!--spring环境-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!--junit环境-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
  </dependencies>
</dependencyManagement>
  • 内置属性
# 调用格式
${basedir}
${version}

# 案例
# 父工程
<groupId>com.itheima</groupId>
    <artifactId>ssm</artifactId>
    <version>1.0-SNAPSHOT</version>

<dependencyManagement>
    <!--具体的依赖-->
    <dependencies>
        <!--添加自己的工程模块依赖-->
        <dependency>
            <groupId>com.itheima</groupId>
            <artifactId>ssm_pojo</artifactId>
            <version>${version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
  • setting属性
# 可以获取maven配置文件settings.xml中的配置

# 调用格式
${settings.localRepository}
  • 打开cmd,输入如下命令查看java系统属性和环境变量属性
mvn help:system

===============================================================================
========================= Platform Properties Details =========================
===============================================================================

===============================================================================
System Properties
===============================================================================

sun.desktop=windows
awt.toolkit=sun.awt.windows.WToolkit
java.specification.version=11
sun.cpu.isalist=amd64
sun.jnu.encoding=GBK
java.class.path=C:\Program Files\apache-maven-3.6.3\bin\..\boot\plexus-classworlds-2.6.0.jar
java.vm.vendor=Oracle Corporation
sun.arch.data.model=64
user.variant=
java.vendor.url=https://openjdk.java.net/
user.timezone=Asia/Shanghai
maven.conf=C:\Program Files\apache-maven-3.6.3\bin\../conf
os.name=Windows 10
java.vm.specification.version=11
sun.java.launcher=SUN_STANDARD
user.country=CN
sun.boot.library.path=C:\Program Files\Java\jdk-11.0.13\bin
sun.java.command=org.codehaus.plexus.classworlds.launcher.Launcher help:system
jdk.debug=release
maven.home=C:\Program Files\apache-maven-3.6.3\bin\..
sun.cpu.endian=little
user.home=C:\Users\ychen
user.language=zh
sun.stderr.encoding=ms936
java.specification.vendor=Oracle Corporation
java.version.date=2021-10-19
java.home=C:\Program Files\Java\jdk-11.0.13
file.separator=\
java.vm.compressedOopsMode=Zero based
line.separator=

sun.stdout.encoding=ms936
java.specification.name=Java Platform API Specification
java.vm.specification.vendor=Oracle Corporation
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
user.script=
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=11.0.13+10-LTS-370
user.name=ychen
path.separator=;
os.version=10.0
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=GBK
guice.disable.misplaced.annotation.check=true
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.version=18.9
java.vendor.url.bug=https://bugreport.java.com/bugreport/
java.io.tmpdir=C:\Users\ychen\AppData\Local\Temp\
java.version=11.0.13
user.dir=C:\Windows\System32
os.arch=amd64
maven.multiModuleProjectDirectory=C:\Windows\System32
java.vm.specification.name=Java Virtual Machine Specification
java.awt.printerjob=sun.awt.windows.WPrinterJob
sun.os.patch.level=
java.library.path=C:\Program Files\Java\jdk-11.0.13\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\app\ychen\product\11.2.0\dbhome_1\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;"C:\Program Files\Java\jdk-11.0.13\bin;C:\Program Files\Java\jdk-11.0.13\jre\bin;";C:\Program Files\apache-maven-3.6.3\bin;C:\Program Files\gradle-7.3.3\bin;C:\Program Files\nodejs\;C:\Program Files\OpenSSL-Win64\bin;"C:\Program Files\apache-tomcat-9.0.56\bin;";C:\ProgramData\chocolatey\bin;C:\work\Rocket_1000;C:\Program Files\Git\cmd;C:\Users\ychen\AppData\Local\Microsoft\WindowsApps;C:\Users\ychen\AppData\Roaming\npm;C:\Users\ychen\AppData\Local\Programs\Microsoft VS Code\bin;.
java.vendor=Oracle Corporation
java.vm.info=mixed mode
java.vm.version=11.0.13+10-LTS-370
classworlds.conf=C:\Program Files\apache-maven-3.6.3\bin\..\bin\m2.conf
sun.io.unicode.encoding=UnicodeLittle
library.jansi.path=C:\Program Files\apache-maven-3.6.3\bin\..\lib\jansi-native
java.class.version=55.0

===============================================================================
Environment Variables
===============================================================================

USERDOMAIN_ROAMINGPROFILE=DESKTOP-9IS6F66
PATH=C:\app\ychen\product\11.2.0\dbhome_1\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;"C:\Program Files\Java\jdk-11.0.13\bin;C:\Program Files\Java\jdk-11.0.13\jre\bin;";C:\Program Files\apache-maven-3.6.3\bin;C:\Program Files\gradle-7.3.3\bin;C:\Program Files\nodejs\;C:\Program Files\OpenSSL-Win64\bin;"C:\Program Files\apache-tomcat-9.0.56\bin;";C:\ProgramData\chocolatey\bin;C:\work\Rocket_1000;C:\Program Files\Git\cmd;C:\Users\ychen\AppData\Local\Microsoft\WindowsApps;C:\Users\ychen\AppData\Roaming\npm;C:\Users\ychen\AppData\Local\Programs\Microsoft VS Code\bin
PROCESSOR_LEVEL=23
SYSTEMDRIVE=C:
ALLUSERSPROFILE=C:\ProgramData
PROCESSOR_ARCHITECTURE=AMD64
DRIVERDATA=C:\Windows\System32\Drivers\DriverData
MAVEN_HOME=C:\Program Files\apache-maven-3.6.3\bin\..
PROGRAMFILES=C:\Program Files
PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PROGRAMDATA=C:\ProgramData
CHOCOLATEYLASTPATHUPDATE=132961062875310469
USERNAME=ychen
TOMCAT_HOME=C:\Program Files\apache-tomcat-9.0.56
WDIR=C:\
ONEDRIVE=C:\Users\ychen\OneDrive
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
CLASSWORLDS_JAR="C:\Program Files\apache-maven-3.6.3\bin\..\boot\plexus-classworlds-2.6.0.jar"
WINDIR=C:\WINDOWS
ROCKET=C:\work\Rocket_1000
HOMEPATH=\Users\ychen
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
PUBLIC=C:\Users\Public
=EXITCODE=00000001
LOCALAPPDATA=C:\Users\ychen\AppData\Local
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
USERDOMAIN=DESKTOP-9IS6F66
LOGONSERVER=\\DESKTOP-9IS6F66
JAVA_HOME=C:\Program Files\Java\jdk-11.0.13
PROMPT=$P$G
PROGRAMFILES(X86)=C:\Program Files (x86)
ERROR_CODE=0
EXEC_DIR=C:\Windows\System32
GRADLE_HOME=C:\Program Files\gradle-7.3.3
=C:=C:\Windows\System32
APPDATA=C:\Users\ychen\AppData\Roaming
GRADLE_USER_HOME=C:\work\gradle
PROGRAMW6432=C:\Program Files
SYSTEMROOT=C:\WINDOWS
CHOCOLATEYINSTALL=C:\ProgramData\chocolatey
MAVEN_CMD_LINE_ARGS=help:system
OS=Windows_NT
COMPUTERNAME=DESKTOP-9IS6F66
COMMONPROGRAMW6432=C:\Program Files\Common Files
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMSPEC=C:\WINDOWS\system32\cmd.exe
JAVACMD=C:\Program Files\Java\jdk-11.0.13\bin\java.exe
MAVEN_PROJECTBASEDIR=C:\Windows\System32
PROCESSOR_REVISION=6001
CLASSPATH=C:\Program Files\Java\jdk-11.0.13\lib\dt.jar;C:\Program Files\Java\jdk-11.0.13\lib\tools.jar;C:\Program Files\apache-tomcat-9.0.56\lib\servlet-api.jar;
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
TEMP=C:\Users\ychen\AppData\Local\Temp
HOMEDRIVE=C:
USERPROFILE=C:\Users\ychen
TMP=C:\Users\ychen\AppData\Local\Temp
NUMBER_OF_PROCESSORS=16
JVMCONFIG=\.mvn\jvm.config
  • 读取java属性
${user.home}
  • 读取环境变量属性
${env.JAVA_HOME}
posted @ 2022-08-14 10:00  DogLeftover  阅读(19)  评论(0编辑  收藏  举报