导入依赖坐标,无需手动导入jar包就可以引入jar。在pom.xml中使用<dependency>
标签引入依赖。
做项目/工作里面 都有整套的依赖的, 不需要背诵的.
或者可以去Maven官网找, 复制,粘贴即可.
例如:我们查找一下 junit 的坐标依赖, 访问 https://mvnrepository.com/
image-20201213195704285
image-20201213195812875
image-20201213195841055
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
image-20201213200004303
<!--引入junit的依赖 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
image-20201213200050438
public class DemoTest {
@Test
public void test01(){
System.out.println("Demo Test...");
}
}
image-20201213200152945
image-20201213200228478
image-20201213200245924
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
image-20201213200503721
<!--引入servlet的依赖-->
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
image-20201213200603252
image-20201213200903462
其中范围的说明如下: