In addition to the comment, there is more important semantic difference: "Provided" dependencies are expected to be supplied by the container, so if your container gives you hibernate, you should mark hibernate as provided.
Optional dependencies are mainly used to reduce the transitive burden of some libraries. For example: If you can use a library with 5 different database types, but you usually only require one, you can mark the library-dependent dependencies as optional, so that the user can supply the one they actually use. If you don't do, you might get two types of problems:
The library pulls a huge load of transitive dependencies of which you actually need very few so that you blow up your project without reason.
More dangerously: You might pull two libraries with overlapping classes, so that the class loader cannot load both of them. This might lead to unexpected behaviour of your library.
optional
will still involve in transitive dependency resolution whileprovided
will not. For example, u haveA
depends onB
and optionally onC:1.0
,B
(not optionally) depends onC:2.0
, the result will beA
is having non-optional dependency (coz transitively fromB
), with version1.0
(cozC:1.0
is closest). Just my guess but not proved, you may have a try