Skip to content
Ameen Abozaid
In reviewJNR-002-L01

Dependency scopes

  • Lesson 1 of 8
  • 11 min read
  • Junior
On This Lesson 4 topics

The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.

In this lesson

choose the right scope for each dependency.

Planned topics

  • A scope says when a dependency is needed: compile, test, or run.
  • compile (default): needed to build and run. Example: a library you call in your code.
  • provided: needed to build, but the server supplies it at run time.
  • runtime: not needed to compile, only to run. Example: a database driver.
  • test: only for tests. Example: JUnit. Never use compile for test libraries.
Draft outline details

Demonstration

xml
<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter</artifactId>
  <version>${junit.version}</version>
  <scope>test</scope>
</dependency>

Check your understanding

Which scope for a JDBC driver you never call directly?

Show answer

runtime.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.