首先得下载安装maven到阿里云服务器上面,具体见菜鸟教程:
https://www.runoob.com/maven/maven-setup.html
再使用xftp工具,把java的整个文件夹(注意:不是jar包)传到服务器
然后通过命令,启动main函数:
1、首先需要编译java工程,生成class文件:mvn compile
2、不存在参数的情况下:mvn exec:java -Dexec.mainClass="com.testDemo.HelloWorld"
3、存在参数:mvn exec:java -Dexec.mainClass="com.testDemo.HelloWorld" -Dexec.args="arg0 arg1 arg2"
4、指定运行时库:mvn exec:java -Dexec.mainClass="com.testDemo.HelloWorld" -Dexec.classpathScope=runtime
需要注意的是命令行要在pom.xml文件所在的目录下运行,不然会报错,找不到pom.xml文件。然后就能正常启动了。截图如下