SBT中无GroupID与Revision的libraryDependencies用法及版本疑问
guice Dependency Shortcut in Play 2.6.x Great question! This shortcut is one of the conveniences Play's sbt plugin provides to simplify your build configuration. Let's break down what's happening here:
Why does libraryDependencies += guice work?
The guice here isn't a random string—it's a predefined ModuleID variable provided by the Play sbt plugin. Play's plugin predefines these shortcuts for common dependencies that integrate tightly with the framework, so you don't have to type out the full groupID % artifactID % revision every time.
Under the hood, this alias maps to the full Guice dependency (usually com.google.inject % guice % [compatible-version]), where the version is managed directly by Play.
How to find the exact Guice version being used?
You have a few straightforward ways to check:
- Use sbt shell commands: Run
show libraryDependenciesin your sbt shell. This will print all your project's dependencies with their full coordinates, including the resolved version of Guice. - Check the resolution report: Look in
target/resolution-cache/reports/default-ivy-report.xml(generated after any sbt task that resolves dependencies) and search for "guice"—you'll find the exact version listed there. - Play's version compatibility docs: Each Play release specifies the compatible Guice version (for Play 2.6.x, it's typically a Guice 4.x release). The framework maintains these versions to ensure compatibility between Play's internals and Guice.
What's the special purpose of this format?
This shortcut serves two key goals:
- Simplified configuration: No need to memorize or type out the full Maven coordinates for core framework dependencies. It keeps your
build.sbtclean and concise. - Version consistency: Play manages the version of Guice tied to this alias, so you don't have to worry about picking a version that conflicts with Play's internal dependencies. If you manually specified a Guice version, you might accidentally introduce compatibility issues—using the
guicealias avoids that risk.
内容的提问来源于stack exchange,提问作者mzrc

