master
zzh 2024-08-08 09:18:00 +08:00
commit 3d336caaa6
6 changed files with 209 additions and 0 deletions

33
.gitignore vendored 100644
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/

80
pom.xml 100644
View File

@ -0,0 +1,80 @@
<?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>
<groupId>com.bwie</groupId>
<artifactId>rikao19</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rikao19</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.bwie.Rikao19Application</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

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

View File

@ -0,0 +1,20 @@
package com.bwie.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @Authorzhangzhihao
* @nameStudent
* @Date2024/8/8 8:40
*
*/
@Data
@AllArgsConstructor
public class Student {
private Integer id;
private String name;
private String course;
private Double score;
}

View File

@ -0,0 +1,50 @@
package com.bwie.test;
import com.bwie.domain.Student;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Authorzhangzhihao
* @nameTest
* @Date2024/8/8 8:41
*
*/
@RestController
public class Test {
@PostMapping("/test")
public void test(){
//创建对象
Student student1 = new Student(1,"张三","语文",77.4);
Student student2 = new Student(2,"王五","数学",66.6);
Student student3 = new Student(3,"赵六","历史",88.8);
Student student4 = new Student(4,"李四","语文",99.0);
Student student5 = new Student(5,"田七","数学",88.0);
List<Student> studentList = new ArrayList<>();
//把数据添加到集合
studentList.add(student1);
studentList.add(student2);
studentList.add(student3);
studentList.add(student4);
studentList.add(student5);
//stream输出
List<String> collect = studentList.stream().map(student -> {
String name = student.getName();
Double score = student.getScore();
return name + ":" + score;
}).collect(Collectors.toList());
System.out.println(collect);
}
}

View File

@ -0,0 +1,13 @@
package com.bwie;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Rikao19ApplicationTests {
@Test
void contextLoads() {
}
}