[英]Can I use Maven without setting the Environment variable?
I want to use Maven for my project.我想在我的项目中使用 Maven。
In my office computer , I don't have the Admin privilege .在我的办公室电脑上,我没有 Admin 权限。 Hence I am not able to set the "System Variable".
因此我无法设置“系统变量”。 I have access only to "User Variable" where I can set only the Java_Home.
我只能访问“用户变量”,我只能在其中设置 Java_Home。
Can I use Maven without adding the M2_Home and editing the Path variable ?我可以在不添加M2_Home和编辑Path变量的情况下使用Maven吗?
It depends if you are using it inside an ide or building project from terminal.这取决于您是在 ide 中使用它还是从终端构建项目。
If you are building using CLI you can invoke maven using the full path for instance :如果您使用 CLI 构建,则可以使用完整路径调用 maven,例如:
/home/<your_folder>/tools/apache-maven-3.5.0/bin/mvn clean install
from your project path /home/<your_folder>/tools/apache-maven-3.5.0/bin/mvn clean install
从你的项目路径/home/<your_folder>/tools/apache-maven-3.5.0/bin/mvn clean install
即使您不是管理员,您也可以设置 M2_HOME 用户变量,并且不需要变量路径,您可以轻松地引用 maven fullpath bin 目录执行相同的任务。
Sure you can, you just need to build your project from maven home actualy当然可以,你只需要从 maven home 实际构建你的项目
If you don't have admin rights, simply set the path till Maven's bin in lets say MAVEN_HOME in user variables.如果您没有管理员权限,只需设置路径,直到 Maven 的 bin 在用户变量中说 MAVEN_HOME 。
Then go to the Path variable in user variables and add MAVEN_HOME to it.然后转到用户变量中的 Path 变量并将 MAVEN_HOME 添加到其中。
You are all set then, just go to command prompt and type mvn -version and you should be good with maven setup in your system.一切就绪,只需转到命令提示符并键入 mvn -version ,您就可以在系统中使用 Maven 设置。
We can add .bat file and link it to cmd by default so whenever you open the terminal that code will execute and set your variable默认情况下,我们可以添加 .bat 文件并将其链接到 cmd,因此每当您打开终端时,代码都会执行并设置您的变量
You can refer more in detail here .您可以在此处详细参考。
Update:更新:
For Windows 10 user can add detail for your account and doesn't require admin access.对于 Windows 10,用户可以为您的帐户添加详细信息,并且不需要管理员访问权限。 Search for below text in windows search bar
在 Windows 搜索栏中搜索以下文本
Edit Environment variables for your Account为您的帐户编辑环境变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.