简体   繁体   English

我可以在不设置环境变量的情况下使用 Maven 吗?

[英]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 using an IDE, there is probably an embedded maven ( there is one inside Eclipse and Intellij IDEA)如果您使用的是 IDE,则可能有一个嵌入式 maven(Eclipse 和 Intellij IDEA 中有一个)
  • 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 实际构建你的项目

Here is an example from stackoverflow 这是stackoverflow的一个例子

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 。 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.

相关问题 设置Maven环境变量 - Setting Maven environment variable Ubuntu Maven环境变量设置麻烦 - Ubuntu Maven environment variable setting trouble 如何在没有 maven 环境的情况下导入 Java package? - How can I import a Java package without maven environment? 没有Maven的情况下如何使用Arquillian? - How can I use Arquillian without Maven? 如何使用Spring 3.2.3 JavaConfig读取环境变量? - How can I use Spring 3.2.3 JavaConfig to read an environment variable? 我可以为Spring FileSystemResource使用基于环境变量的位置吗? - Can I use an Environment variable based location for Spring FileSystemResource? 如何在休眠配置文件中使用环境变量? - How can I use environment variable in hibernate config file? 在 maven 构建过程中,我应该如何配置 eclipse 以针对不同的 maven 阶段使用不同的环境变量值? - How should I configure the eclipse to make use of different values of environment variable for different maven phases, during maven building process? 我可以在不使用ANT或Maven的情况下将Travis CI与Jav​​a一起使用吗? - Can I use Travis CI with Java without using ANT or Maven? 如何验证我的MAVEN_OPTS环境变量是否正在传递给正在启动的java进程? - How can I verify that my MAVEN_OPTS environment variable is being passed to the java process being started?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM