parent
9b5408cf46
commit
c8574d097d
|
@ -19,11 +19,6 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 自己的模块 -->
|
<!-- 自己的模块 -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.atguigu</groupId>
|
|
||||||
<artifactId>spzx-model</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atguigu</groupId>
|
<groupId>com.atguigu</groupId>
|
||||||
<artifactId>common-util</artifactId>
|
<artifactId>common-util</artifactId>
|
||||||
|
|
|
@ -24,11 +24,7 @@
|
||||||
<artifactId>spzx-model</artifactId>
|
<artifactId>spzx-model</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Spring-Web -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- fastjson依赖 -->
|
<!-- fastjson依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
|
|
|
@ -18,6 +18,39 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>common-util</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- gateway -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- loadbalancer依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 服务注册 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- config -->
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>com.alibaba.cloud</groupId> -->
|
||||||
|
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
|
||||||
|
<!-- 服务保护组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.atguigu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hello world!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class App
|
|
||||||
{
|
|
||||||
public static void main( String[] args )
|
|
||||||
{
|
|
||||||
System.out.println( "Hello World!" );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.atguigu.gateway;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class GatewayApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(GatewayApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
bunny:
|
||||||
|
nacos:
|
||||||
|
server-addr: z-bunny.cn:8848
|
||||||
|
discovery:
|
||||||
|
namespace: spzx
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
server:
|
||||||
|
port: 8500
|
||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
|
application:
|
||||||
|
name: server-gateway
|
||||||
|
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
namespace: ${bunny.nacos.discovery.namespace}
|
||||||
|
server-addr: ${bunny.nacos.server-addr}
|
||||||
|
gateway:
|
||||||
|
discovery:
|
||||||
|
locator:
|
||||||
|
enabled: true
|
||||||
|
# 解决跨域
|
||||||
|
globalcors:
|
||||||
|
cors-configurations:
|
||||||
|
'[/**]':
|
||||||
|
allowedOriginPatterns: "*"
|
||||||
|
# 允许请求中携带的头信息
|
||||||
|
allowedHeaders: "*"
|
||||||
|
# 运行跨域的请求方式
|
||||||
|
allowedMethods: "*"
|
||||||
|
# 跨域检测的有效期,单位s
|
||||||
|
maxAge: 36000
|
||||||
|
# 路由
|
||||||
|
routes:
|
||||||
|
- id: service-product
|
||||||
|
uri: lb://service-product
|
||||||
|
predicates:
|
||||||
|
- Path=/*/product/**
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.atguigu.product.mapper: debug
|
||||||
|
com.atguigu.product.controller: info
|
||||||
|
com.atguigu.product.service: info
|
||||||
|
pattern:
|
||||||
|
dateformat: HH:mm:ss:SSS
|
||||||
|
file:
|
||||||
|
path: "logs/${spring.application.name}"
|
|
@ -0,0 +1,16 @@
|
||||||
|
-----------------▄██-█▄---------
|
||||||
|
-----------------███▄██▄--------
|
||||||
|
-----------------███████--------
|
||||||
|
-----------------▀███████-------
|
||||||
|
-------------------██████▄▄-----
|
||||||
|
-------------------█████████▄---
|
||||||
|
-------------------██████▄████--
|
||||||
|
-------▄███████████████████████-
|
||||||
|
-----▄███████████████████████▀--
|
||||||
|
---▄██████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
-▄▄██████████████████████▀------
|
||||||
|
-█████████████████▀█████--------
|
||||||
|
-▀██████████████▀▀-▀█████▄------
|
||||||
|
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs/service-product/logs"/>
|
||||||
|
|
||||||
|
<!--控制台日志格式:彩色日志-->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<!-- boldMagenta:粗红-->
|
||||||
|
<!-- cyan:青色 -->
|
||||||
|
<!-- white:白色 -->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) %highlight([%-5level]) %green(%logger) %msg%n"/>
|
||||||
|
|
||||||
|
<!--文件日志格式-->
|
||||||
|
<property name="FILE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n"/>
|
||||||
|
|
||||||
|
<!--编码-->
|
||||||
|
<property name="ENCODING" value="UTF-8"/>
|
||||||
|
|
||||||
|
<!-- 控制台日志 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- 临界值过滤器 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 文件日志 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>${log.path}//log.log</file>
|
||||||
|
<append>true</append>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%date{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 开发环境 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<!-- com.atguigu日志记录器:业务程序INFO级别 -->
|
||||||
|
<logger name="com.atguigu" level="INFO"/>
|
||||||
|
<!-- 根日志记录器:INFO级别 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
|
@ -22,11 +22,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atguigu</groupId>
|
<groupId>com.atguigu</groupId>
|
||||||
<artifactId>common-service</artifactId>
|
<artifactId>common-service</artifactId>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -18,7 +17,7 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/product/category/")
|
@RequestMapping("/api/product/category/")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@CrossOrigin
|
// @CrossOrigin
|
||||||
public class CategoryController {
|
public class CategoryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
|
@ -10,7 +10,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -21,7 +20,7 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/api/product/index")
|
@RequestMapping(value = "/api/product/index")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@CrossOrigin
|
// @CrossOrigin
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
|
@ -30,6 +30,7 @@ logging:
|
||||||
com.atguigu.product.mapper: debug
|
com.atguigu.product.mapper: debug
|
||||||
com.atguigu.product.controller: info
|
com.atguigu.product.controller: info
|
||||||
com.atguigu.product.service: info
|
com.atguigu.product.service: info
|
||||||
|
com.alibaba.nacos: info
|
||||||
pattern:
|
pattern:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE configuration PUBLIC
|
|
||||||
"-//mybatis.org//DTD Config 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
|
||||||
<configuration>
|
|
||||||
<settings>
|
|
||||||
<!-- 设置驼峰标识 -->
|
|
||||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
|
||||||
<!-- 打印SQL语句 -->
|
|
||||||
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
|
||||||
</settings>
|
|
||||||
<plugins>
|
|
||||||
<!-- 分页插件 -->
|
|
||||||
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
|
|
||||||
</plugins>
|
|
||||||
</configuration>
|
|
Loading…
Reference in New Issue