[Solved] Maven install failed (package com.google.gson does not exist)

The new class uses gson-1.7.2.jar package, so the compilation reports an error, and the jar package was introduced before, just for the testing phase.

Workaround.

Just remove <scope>test</scope>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.2</version>
<scope>test</scope>
</dependency>

[INFO] 1 error
[INFO] ————————————————————-
[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 4.510s
[INFO] Finished at: Mon Aug 13 11:06:57 CST 2018
[INFO] Final Memory: 39M/394M
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project performance: Compilation failure
[ERROR] /D:/workPath/infinitus/performance/src/main/java/com/infinitus/it/performance/controller/MsgController.java:[20,23] Program package com.google.gson does not exist
[ERROR] -> [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

Similar Posts: