This commit is contained in:
2023-03-09 14:39:16 +08:00
parent c2799fbdc2
commit 50bd645ec5
88 changed files with 1143 additions and 0 deletions

33
springboot_04_junit/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yv</groupId>
<artifactId>springboot_04_junit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot_04_junit</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,13 @@
package com.yv;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Springboot04JunitApplication {
public static void main(String[] args) {
SpringApplication.run(Springboot04JunitApplication.class, args);
}
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,21 @@
package com.yv;
import com.yv.dao.BookDao;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Springboot04JunitApplicationTests {
//1.注入你要测试的对象
@Autowired
private BookDao bookDao;
@Test
void contextLoads() {
//2.执行要测试的对象对应的方法
bookDao.save();
}
}

View File

@@ -0,0 +1,9 @@
package com.yv.dao;
/**
* @author YoVinchen
* @date 2023/3/9 下午 2:31
*/
public interface BookDao {
public void save();
}

View File

@@ -0,0 +1,18 @@
package com.yv.dao.impl;
import com.yv.dao.BookDao;
import org.springframework.stereotype.Repository;
/**
* @author YoVinchen
* @date 2023/3/9 下午 2:31
*/
@Repository
public class BookDaoImpl implements BookDao {
@Override
public void save() {
System.out.println("book dao is running ....");
}
}