Initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package cn.lingniu.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@ComponentScan(basePackages = {"cn.lingniu.*"})
|
||||
@SpringBootApplication
|
||||
public class ProviderDemoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProviderDemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lingniu.demo.web;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Contributor {
|
||||
String login;
|
||||
int contributions;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lingniu.demo.web;
|
||||
|
||||
import cn.lingniu.framework.plugin.core.base.CommonResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping
|
||||
public class GithubApiController {
|
||||
|
||||
@GetMapping("/repos/{owner}/{repo}/contributors")
|
||||
public CommonResult<List<Contributor>> contributors(@PathVariable("owner") String owner, @PathVariable("repo") String repo) {
|
||||
// 模拟返回贡献者列表
|
||||
Contributor contributor1 = new Contributor("user1", 10);
|
||||
Contributor contributor2 = new Contributor("user2", 5);
|
||||
List<Contributor> response = new ArrayList<>();
|
||||
response.add(contributor1);
|
||||
response.add(contributor2);
|
||||
return CommonResult.success(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
framework:
|
||||
lingniu:
|
||||
web:
|
||||
apiLog:
|
||||
#开关
|
||||
enable: true
|
||||
spring:
|
||||
cloud:
|
||||
isOkHttp: false
|
||||
@@ -0,0 +1,15 @@
|
||||
server:
|
||||
port: 8081
|
||||
spring:
|
||||
application:
|
||||
name: lingniu-framework-provider-demo
|
||||
profiles:
|
||||
active: dev,web
|
||||
cloud:
|
||||
nacos:
|
||||
enabled: true #开启微服务自定义注册,自动获取当前框架信息,启动时间等到metadata中
|
||||
discovery:
|
||||
server-addr: http://nacos-uat-new-inter.xx.net.cn:8848 #注册中心地址
|
||||
username: nacos_test #注册中心用户名
|
||||
password: nacos_test #注册中心密码
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
||||
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="10 seconds">
|
||||
|
||||
<contextName>logback</contextName>
|
||||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
||||
<!-- <property name="log.path" value="/opt/application/config/logs"/>-->
|
||||
<property name="log.path" value="/Users/likobe/logs/"/>
|
||||
|
||||
<!--输出到控制台-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--日志文件输出格式-->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<append>true</append>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${log.path}/log-%d{yyyy-MM-dd-HH}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>30MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>7</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="org.mybatis" level="debug"/>
|
||||
|
||||
<springProfile name="dev">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
<springProfile name="test">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
<springProfile name="pro">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user