基础版本完成
This commit is contained in:
		
							
								
								
									
										37
									
								
								book-service/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								book-service/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
			
		||||
    <modelVersion>4.0.0</modelVersion>
 | 
			
		||||
    <parent>
 | 
			
		||||
        <groupId>com.example</groupId>
 | 
			
		||||
        <artifactId>SpringCloudStudy</artifactId>
 | 
			
		||||
        <version>0.0.1-SNAPSHOT</version>
 | 
			
		||||
    </parent>
 | 
			
		||||
 | 
			
		||||
    <groupId>org.example</groupId>
 | 
			
		||||
    <artifactId>book-service</artifactId>
 | 
			
		||||
 | 
			
		||||
    <properties>
 | 
			
		||||
        <maven.compiler.source>8</maven.compiler.source>
 | 
			
		||||
        <maven.compiler.target>8</maven.compiler.target>
 | 
			
		||||
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
			
		||||
    </properties>
 | 
			
		||||
 | 
			
		||||
    <dependencies>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework.boot</groupId>
 | 
			
		||||
            <artifactId>spring-boot-starter-web</artifactId>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.mybatis.spring.boot</groupId>
 | 
			
		||||
            <artifactId>mybatis-spring-boot-starter</artifactId>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.example</groupId>
 | 
			
		||||
            <artifactId>commons</artifactId>
 | 
			
		||||
            <version>0.0.1-SNAPSHOT</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 | 
			
		||||
</project>
 | 
			
		||||
							
								
								
									
										19
									
								
								book-service/src/main/java/com/test/BookApplication.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								book-service/src/main/java/com/test/BookApplication.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
package com.test;
 | 
			
		||||
 | 
			
		||||
import com.apple.eawt.Application;
 | 
			
		||||
import org.springframework.boot.SpringApplication;
 | 
			
		||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookApplication
 | 
			
		||||
 * Package: com.test
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 16:23
 | 
			
		||||
 */
 | 
			
		||||
@SpringBootApplication
 | 
			
		||||
public class BookApplication {
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        SpringApplication.run(BookApplication.class,args);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,28 @@
 | 
			
		||||
package com.test.controller;
 | 
			
		||||
 | 
			
		||||
import com.test.service.BookService;
 | 
			
		||||
import org.springframework.web.bind.annotation.PathVariable;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookController
 | 
			
		||||
 * Package: com.test.controller
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:11
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
public class BookController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    BookService service;
 | 
			
		||||
 | 
			
		||||
    @RequestMapping("/book/{bid}")
 | 
			
		||||
    Book findBookById(@PathVariable("bid") int bid){
 | 
			
		||||
        return service.getBookById(bid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								book-service/src/main/java/com/test/mapper/BookMapper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								book-service/src/main/java/com/test/mapper/BookMapper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
package com.test.mapper;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Select;
 | 
			
		||||
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookMapper
 | 
			
		||||
 * Package: com.test.mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:02
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface BookMapper {
 | 
			
		||||
 | 
			
		||||
    @Select("select * from DB_BOOK where bid = #{bid}")
 | 
			
		||||
    Book getBookById(int bid);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								book-service/src/main/java/com/test/service/BookService.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								book-service/src/main/java/com/test/service/BookService.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
package com.test.service;
 | 
			
		||||
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookService
 | 
			
		||||
 * Package: com.test.service
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:03
 | 
			
		||||
 */
 | 
			
		||||
public interface BookService {
 | 
			
		||||
    Book getBookById(int bid);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package com.test.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.test.mapper.BookMapper;
 | 
			
		||||
import com.test.service.BookService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookServiceImpl
 | 
			
		||||
 * Package: com.test.service.impl
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:09
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class BookServiceImpl implements BookService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    BookMapper mapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Book getBookById(int bid) {
 | 
			
		||||
        return mapper.getBookById(bid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								book-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								book-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
server:
 | 
			
		||||
  port: 8201
 | 
			
		||||
spring:
 | 
			
		||||
  datasource:
 | 
			
		||||
    driver-class-name: com.mysql.cj.jdbc.Driver
 | 
			
		||||
    url: jdbc:mysql://43.143.164.194:3306/mac
 | 
			
		||||
    username: mac
 | 
			
		||||
    password: mactest
 | 
			
		||||
		Reference in New Issue
	
	Block a user