I need to use a dependency JWT in java for secure token authentication in my Java application.
My question is. Do I need to use all 3 dependencies individual as :
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.0</version>
<scope>runtime</scope>
</dependency>
Or I can use a single one who includes all of them :
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
And why do I need to specify the scope at run-time when
Notice the above dependency declarations all have only one compile-time dependency and the rest are declared as runtime dependencies.
This is because JJWT is designed so you only depend on the APIs that are explicitly designed for you to use in your applications and all other internal implementation details - that can change without warning - are relegated to runtime-only dependencies. This is an extremely important point if you want to ensure stable JJWT usage and upgrades over time:
JJWT guarantees semantic versioning compatibility for all of its artifacts except the jjwt-impl
.jar. No such guarantee is made for the jjwt-impl
.jar and internal changes in that .jar can happen at any time. Never add the jjwt-impl
.jar to your project with compile
scope - always declare it with runtime
scope.
Understanding JJWT Dependencies
question from:
https://stackoverflow.com/questions/65934148/json-web-token-support-for-the-jvm-does-include-impl-api-and-jackson 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…