feat(修复): 共用一个跨域,添加docker文件
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
531a205911
commit
7f08af15b3
|
@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MangerApplication {
|
public class MangerApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
log.info("启动===>MangerApplication");
|
||||||
SpringApplication.run(MangerApplication.class, args);
|
SpringApplication.run(MangerApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs//spzx-manager//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>
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -18,12 +18,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- lombok的依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atguigu</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>common-util</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- gateway -->
|
<!-- gateway -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.atguigu.gateway;
|
package com.atguigu.gateway;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@Slf4j
|
||||||
public class GatewayApplication {
|
public class GatewayApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
log.info("启动===>SpringBootApplication");
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
SpringApplication.run(GatewayApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,16 +17,16 @@ spring:
|
||||||
locator:
|
locator:
|
||||||
enabled: true
|
enabled: true
|
||||||
# 解决跨域
|
# 解决跨域
|
||||||
globalcors:
|
# globalcors:
|
||||||
cors-configurations:
|
# cors-configurations:
|
||||||
'[/**]':
|
# '[/**]':
|
||||||
allowedOriginPatterns: "*"
|
# allowedOriginPatterns: "*"
|
||||||
# 允许请求中携带的头信息
|
# # 允许请求中携带的头信息
|
||||||
allowedHeaders: "*"
|
# allowedHeaders: "*"
|
||||||
# 运行跨域的请求方式
|
# # 运行跨域的请求方式
|
||||||
allowedMethods: "*"
|
# allowedMethods: "*"
|
||||||
# 跨域检测的有效期,单位s
|
# # 跨域检测的有效期,单位s
|
||||||
maxAge: 36000
|
# maxAge: 36000
|
||||||
# 路由
|
# 路由
|
||||||
routes:
|
routes:
|
||||||
- id: service-product
|
- id: service-product
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs//spzx-manager//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>
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.order;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@Slf4j
|
||||||
|
public class OrderApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
log.info("启动===>OrderApplication");
|
||||||
|
SpringApplication.run(OrderApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -5,13 +5,16 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableCaching// 开启缓存注解
|
@EnableCaching// 开启缓存注解
|
||||||
@MapperScan("com.atguigu.product.mapper")
|
@MapperScan("com.atguigu.product.mapper")
|
||||||
|
@ComponentScan("com.atguigu")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProductApplication {
|
public class ProductApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
log.info("启动===>ProductApplication");
|
||||||
SpringApplication.run(ProductApplication.class, args);
|
SpringApplication.run(ProductApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,99 +0,0 @@
|
||||||
package com.atguigu.product.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cache.CacheManager;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
||||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
|
||||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|
||||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@Slf4j
|
|
||||||
public class RedisConfiguration {
|
|
||||||
/**
|
|
||||||
* 使用StringRedisSerializer序列化为字符串
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory connectionFactory) {
|
|
||||||
log.info("RedisConfiguration===>使用StringRedisSerializer序列化为字符串");
|
|
||||||
|
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
|
||||||
redisTemplate.setConnectionFactory(connectionFactory);
|
|
||||||
// 设置key序列化为string
|
|
||||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
|
||||||
// 设置value序列化为JSON,使用GenericJackson2JsonRedisSerializer替换默认序列化
|
|
||||||
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
|
||||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
|
||||||
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
|
||||||
|
|
||||||
return redisTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public CacheManager cacheManager(RedisConnectionFactory factory) {
|
|
||||||
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
|
|
||||||
|
|
||||||
StringRedisSerializer redisSerializer = new StringRedisSerializer();
|
|
||||||
// json序列化
|
|
||||||
Jackson2JsonRedisSerializer<Object> serializer = jsonRedisSerializer();
|
|
||||||
// 配置序列化
|
|
||||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
|
||||||
RedisCacheConfiguration redisCacheConfiguration = config
|
|
||||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
|
||||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(serializer));
|
|
||||||
|
|
||||||
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
|
||||||
.cacheDefaults(redisCacheConfiguration).build();
|
|
||||||
return cacheManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 指定的日期模式
|
|
||||||
*/
|
|
||||||
public Jackson2JsonRedisSerializer<Object> jsonRedisSerializer() {
|
|
||||||
log.info("RedisConfiguration===>指定的日期模式");
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
// 设置ObjectMapper访问权限
|
|
||||||
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
|
||||||
// 记录序列化之后的数据类型,方便反序列化
|
|
||||||
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
|
||||||
// 关闭默认的日期格式化方式,默认UTC日期格式 yyyy-MM-dd’T’HH:mm:ss.SSS
|
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
|
||||||
|
|
||||||
// LocalDatetime序列化,默认不兼容jdk8日期序列化
|
|
||||||
JavaTimeModule timeModule = new JavaTimeModule();
|
|
||||||
timeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
||||||
timeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
||||||
timeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
|
|
||||||
mapper.registerModule(timeModule);
|
|
||||||
return new Jackson2JsonRedisSerializer<>(mapper, Object.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Tag(name = "商品列表管理")
|
@Tag(name = "商品列表管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/product/")
|
@RequestMapping("/api/product")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs//spzx-manager//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>
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.user;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@Slf4j
|
||||||
|
public class UserApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
log.info("启动===>SpringBootApplication");
|
||||||
|
SpringApplication.run(UserApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue