One of Maven's philosophies is that the Convention is better than configuration (Convention over config), and the default value of scope is compile in the MAVEN default dependency configuration item, and the project is often innocently confused and directly default. Comb Maven's scope today. Classification of Scope Compile
The default is compile, and nothing is configured to mean compile. Compile indicates that the dependent project needs to be involved in the compilation of the current project, and of course the subsequent testing and operation Cycles are also involved, a relatively strong dependency. It usually needs to be included in the package. Test
Scope for test indicates that dependent projects are only involved in testing-related work, including the compilation and execution of test code. More typical, such as JUnit. Runntime
Runntime indicates that a dependent project does not need to be involved in the compilation of the project, but later testing and running cycles require its participation. Compared to compile, skip compiling , to be honest in the terminal project (non-open source, enterprise internal system), and compile difference is not very big. More common, such as the implementation of JSRXXX, the corresponding API jar is compile, the implementation is runtime, compile just need to know the interface is enough. The Oracle JDBC driver package is a good example of a general scope of Runntime. In addition, the dependency of runntime is usually used in conjunction with optional, optional is true. I can use a to achieve, can also be implemented with B. provided
Provided means that you can pack it without having to pack it in, and other facilities (Web Container) will provide. In fact, the dependency theory can be involved in compiling, testing, running and other cycles. The equivalent of compile, but in the packaging phase did a exclude action. system
In terms of engagement, the same is provided, but the dependencies are not captured from the Maven repository, but are taken from the local file system and must be used with the Systempath attribute . dependency delivery of scope
A–>b–>c. The current project for A,a relies on b,b dependent on C. Knowing the scope of B in Project A, how do you know the scope of C in a? The answer is:
When C is test or provided, C is discarded directly, a does not depend on C;
Otherwise a dependent c,c scope inherits from the scope of B.
Below is a picture of a nexus picture.
Friendship Link
Calligraphy and Chinese painting enthusiasts come in