When importing to pom.xml when using Maven, I usually pick it up from the net and copy it, but I stumbled on the fact that the
According to the official (Dependency Scope: Maven – Introduction to the Dependency Mechanism), there are five main types. There is a pattern. (6 types including ʻimport` added in Maven 2.0.9, which can be used only in Dependent pom --dependencyManagement)
|Scope type|Description| |:--|:--| | compile |This is the default value when the scope specification is omitted. It will be added to the classpath in all situations.| | provided |Specify if the library is provided by the JDK or container. It is added to the classpath only at compile time.| | runtime |Specify if required only at runtime. It is added to the classpath during test execution and normal execution.| | test |Specify if required only for testing. It is added to the classpath when compiling and running the test.| | system |Specify if you want to explicitly add it to the classpath. Libraries in this scope are always considered valid and do not search the repository.|
At pinpoint, I was at a loss because there were cases where there was a scope for JDBC as shown below, but [Maven dependency range --CodeFlow](https://www.codeflow.site/ja/article/maven- According to dependency-scopes), the runtime seems to be good.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
<scope>runtime</scope>
</dependency>
Recommended Posts