Maven构建可在Windows上运行,但在Linux上无法运行

时间:2019-03-04 10:33:37

标签: maven maven-3 pom.xml

我有一些基于Maven的项目。

同一项目在Windows上构建良好,但在linux上失败

Windows ---------------:

C:\project\code\microservice\ConfigService>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.conf:ConfigService >----------------------
[INFO] Building ConfigService 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ ConfigService ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ ConfigService ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ConfigService ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 51 source files to C:\project\code\microservice\ConfigService\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ ConfigService ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\project\code\microservice\ConfigService\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ConfigService ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ ConfigService ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ ConfigService ---
[INFO] Building jar: C:\project\code\microservice\ConfigService\target\ConfigService-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:repackage (repackage) @ ConfigService ---
[INFO] Replacing main artifact C:\project\code\microservice\ConfigService\target\ConfigService-0.0.1-SNAPSHO
T.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.811 s
[INFO] Finished at: 2019-03-04T15:42:57+05:30
[INFO] ------------------------------------------------------------------------

Linux ------------

user@myhost:~/project/work/ConfigService$ mvn clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.conf:ConfigService >----------------------
[INFO] Building ConfigService 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ ConfigService ---
[INFO] Deleting /home/user/project/work/ConfigService/target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ ConfigService ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ConfigService ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 51 source files to /home/user/project/work/ConfigService/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.479 s
[INFO] Finished at: 2019-03-04T05:28:06-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ConfigService: Compilation failure -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

那么,导致此问题的主要原因是什么,从其他选项来看一切正常

在ubuntu上,我有Java版本

Apache Maven 3.6.0(97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00) Maven主页:/home/user/tools/maven/apache-maven-3.6.0 Java版本:1.8.0_191,供应商:Oracle Corporation,运行时:/ usr / lib / jvm / java-8-openjdk-amd64 / jre 默认语言环境:en_US,平台编码:UTF-8 操作系统名称:“ linux”,版本:“ 4.15.0-29-generic”,拱门:“ amd64”,家族:“ unix”

在Windows上

Apache Maven 3.6.0(97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T00:11:47 + 05:30) Maven主页:C:\ project \ softs \ apache-maven-3.6.0 \ bin .. Java版本:1.8.0_201,供应商:Oracle Corporation,运行时:C:\ Program Files \ Java \ jdk1.8.0_201 \ jre 默认语言环境:en_US,平台编码:Cp1252 操作系统名称:“ windows 7”,版本:“ 6.1”,拱门:“ amd64”,家族:“ windows

1 个答案:

答案 0 :(得分:0)

如果您粘贴的日志是原始日志,那么我可以看到linux路径不正确

/home/user/project/work/ConfigServicetarget/classes

在ConfigService之后,应使用/

尝试在文件中查看缺少哪个配置,或者您需要提供源代码。