日考14
commit
3919b0d7c6
|
@ -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/
|
|
@ -0,0 +1,95 @@
|
|||
<?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>rikao14</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>rikao14</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>
|
||||
<!-- Druid数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</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.Rikao14Application</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.bwie.mapper")
|
||||
public class Rikao14Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Rikao14Application.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.domain.Comment;
|
||||
import com.bwie.service.CommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:zhangzhihao
|
||||
* @name:CommentController
|
||||
* @Date:2024/8/7 18:41
|
||||
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||
*/
|
||||
@RestController
|
||||
public class CommentController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CommentService commentService;
|
||||
|
||||
@PostMapping("/findComment")
|
||||
public List<Comment> findComment(){
|
||||
|
||||
return commentService.findComment();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
/**
|
||||
* @Author:zhangzhihao
|
||||
* @name:Comment
|
||||
* @Date:2024/8/7 18:40
|
||||
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||
*/
|
||||
public class Comment {
|
||||
private String id;
|
||||
private String commentContent;
|
||||
private String creatTime;
|
||||
|
||||
public Comment(String id, String commentContent, String creatTime) {
|
||||
this.id = id;
|
||||
this.commentContent = commentContent;
|
||||
this.creatTime = creatTime;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCommentContent() {
|
||||
return commentContent;
|
||||
}
|
||||
|
||||
public void setCommentContent(String commentContent) {
|
||||
this.commentContent = commentContent;
|
||||
}
|
||||
|
||||
public String getCreatTime() {
|
||||
return creatTime;
|
||||
}
|
||||
|
||||
public void setCreatTime(String creatTime) {
|
||||
this.creatTime = creatTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.bwie.domain.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:zhangzhihao
|
||||
* @name:CommentMapper
|
||||
* @Date:2024/8/7 18:40
|
||||
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||
*/
|
||||
public interface CommentMapper {
|
||||
List<Comment> findComment();
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.domain.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:zhangzhihao
|
||||
* @name:Comment
|
||||
* @Date:2024/8/7 18:40
|
||||
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||
*/
|
||||
public interface CommentService {
|
||||
List<Comment> findComment();
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.bwie.service.Impl;
|
||||
|
||||
import com.bwie.domain.Comment;
|
||||
import com.bwie.mapper.CommentMapper;
|
||||
import com.bwie.service.CommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:zhangzhihao
|
||||
* @name:CommentServiceImpl
|
||||
* @Date:2024/8/7 18:40
|
||||
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||
*/
|
||||
@Service
|
||||
public class CommentServiceImpl implements CommentService {
|
||||
|
||||
@Autowired
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Override
|
||||
public List<Comment> findComment() {
|
||||
return commentMapper.findComment();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
# spring配置
|
||||
spring:
|
||||
redis:
|
||||
host: 49.235.138.50
|
||||
port: 6379
|
||||
password: 12345678901zzh
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: bwie
|
||||
loginPassword: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://49.235.138.50:3306/rikao14?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 12345678901@zzh
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
# mybatis配置
|
||||
mybatis:
|
||||
# 搜索指定包别名
|
||||
typeAliasesPackage: com.bwie.domain
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapperLocations: classpath:mapper/**/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
# 将mapper接口所在包的日志级别改成debug,可以在控制台打印sql
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bwie.mapper.CommentMapper">
|
||||
|
||||
|
||||
<select id="findComment" resultType="com.bwie.domain.Comment">
|
||||
select * from t_comment order by creat_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,13 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Rikao14ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue