Pregunta

If I include a library (e.g. mycompany.model.core-SNAPSHOT) within an application (e.g. my.company.app), and mycompany.model.core contains Hibernate as a dependency, can I reference Hibernate classes and functions within my.company.app WITHOUT including hibernate (explicitly) in the app?

Thanks!

¿Fue útil?

Solución

You can, but it's not considered good practice.

If you need a class or interface to be on the classpath in order to compile your application, you should add a <dependency> for it. This protects you from changes to your upstream dependencies (e.g. if the library that you depend on switches to TopLink instead of Hibernate) and allows Maven to notice if the version numbers of your direct and indirect dependencies get out of sync.

Since you control both the library and the application artifacts, why not make them both inherit from a common parent pom.xml? Then you can manage the versions of your dependencies (e.g., your Hibernate version) from one place.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top