所以,我一直在为一些代码编写单元测试,我注意到当我运行 Maven 命令时它们无法正确运行。我什至没有收到错误。它返回一大堆行。它似乎在寻找什么。我有 Java 21 和 Maven 版本 3.9.9
这就是我运行一个简单命令时返回的内容
mvn -v
。
usage: java [options] ,mainclass. [args....]
(to execute a class)
or java [options] -jar <jarfile> [args....]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Arguments following the main class, source file, -jar <jarfile>,
-m or --module <module>/<mainclass> are passed as the arguments to
main class.
where options include:
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
我尝试编辑环境变量并重新安装 Maven。我也重新启动了机器,但没有运气。
从 CMD 提示符运行 java -version 并确保系统找到它。验证您的路径变量。