Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringCloudAlibaba
提交
f3c2e916
S
SpringCloudAlibaba
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringCloudAlibaba
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringCloudAlibaba
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f3c2e916
编写于
2月 10, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:服务提供者
上级
43322a7e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
298 addition
and
28 deletion
+298
-28
nacos-server-producer/pom.xml
nacos-server-producer/pom.xml
+26
-8
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/NacosProducerApplication.java
...com/kwan/springcloudalibaba/NacosProducerApplication.java
+3
-1
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/config/MyBatisPlusConfig.java
...com/kwan/springcloudalibaba/config/MyBatisPlusConfig.java
+31
-0
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/controller/NacosProducerController.java
...pringcloudalibaba/controller/NacosProducerController.java
+1
-5
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/controller/UserController.java
...om/kwan/springcloudalibaba/controller/UserController.java
+44
-0
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/entity/User.java
...rc/main/java/com/kwan/springcloudalibaba/entity/User.java
+24
-0
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/mapper/UserMapper.java
...n/java/com/kwan/springcloudalibaba/mapper/UserMapper.java
+20
-0
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/service/IUserService.java
...ava/com/kwan/springcloudalibaba/service/IUserService.java
+32
-0
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/service/impl/UserServiceImpl.java
...kwan/springcloudalibaba/service/impl/UserServiceImpl.java
+37
-0
nacos-server-producer/src/main/resources/bootstrap.yml
nacos-server-producer/src/main/resources/bootstrap.yml
+2
-14
nacos-server-producer/src/main/resources/logback-spring.xml
nacos-server-producer/src/main/resources/logback-spring.xml
+69
-0
nacos-server-producer/src/main/resources/mapper/UserMapper.xml
...-server-producer/src/main/resources/mapper/UserMapper.xml
+9
-0
未找到文件。
nacos-server-producer/pom.xml
浏览文件 @
f3c2e916
...
@@ -2,18 +2,14 @@
...
@@ -2,18 +2,14 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<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"
>
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>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<parent>
<groupId>
com.kwan.springcloudalibaba
</groupId>
<groupId>
com.kwan.springcloudalibaba
</groupId>
<artifactId>
nacos-server-parent
</artifactId>
<artifactId>
nacos-server-parent
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<version>
1.0.0-SNAPSHOT
</version>
</parent>
</parent>
<artifactId>
nacos-server-producer
</artifactId>
<artifactId>
nacos-server-producer
</artifactId>
<name>
nacos-server-producer
</name>
<name>
nacos-server-producer
</name>
<description>
nacos-server-producer
</description>
<description>
nacos-server-producer
</description>
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
...
@@ -27,12 +23,10 @@
...
@@ -27,12 +23,10 @@
<artifactId>
nacos-server-common
</artifactId>
<artifactId>
nacos-server-common
</artifactId>
<version>
1.0.0
</version>
<version>
1.0.0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
@@ -54,6 +48,30 @@
...
@@ -54,6 +48,30 @@
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.4.3
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.2.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.11
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.10
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/NacosProducerApplication.java
浏览文件 @
f3c2e916
...
@@ -2,6 +2,7 @@ package com.kwan.springcloudalibaba;
...
@@ -2,6 +2,7 @@ package com.kwan.springcloudalibaba;
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.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
/**
/**
...
@@ -11,10 +12,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
...
@@ -11,10 +12,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @version : 2.2.0
* @version : 2.2.0
* @date : 2023/1/17 12:37
* @date : 2023/1/17 12:37
*/
*/
@SpringBootApplication
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
public
class
NacosProducerApplication
{
public
class
NacosProducerApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
NacosProducerApplication
.
class
,
args
);
SpringApplication
.
run
(
NacosProducerApplication
.
class
,
args
);
System
.
out
.
println
(
"-----------------------nacos-server-producer启动成功-----------------------"
);
}
}
}
}
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/config/MyBatisPlusConfig.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.config
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* mybatisplus配置
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/12/19 16:11
*/
@MapperScan
(
"com.kwan.springcloudalibaba.mapper"
)
//扫描我们的mapper文件夹 这里添加了@MapperScan注解就不需要Springboot启动类上加入@MapperScan注解了
@Configuration
//配置类
public
class
MyBatisPlusConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
//注册乐观锁插件
interceptor
.
addInnerInterceptor
(
new
OptimisticLockerInnerInterceptor
());
//分页插件
interceptor
.
addInnerInterceptor
(
new
PaginationInnerInterceptor
(
DbType
.
MYSQL
));
return
interceptor
;
}
}
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/controller/NacosProducerController.java
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.controller
;
package
com.kwan.springcloudalibaba.controller
;
import
com.kwan.springcloudalibaba.common.Result
;
import
com.kwan.springcloudalibaba.common.Result
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
@@ -14,16 +13,13 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -14,16 +13,13 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/nacos/producer"
)
@RequestMapping
(
"/nacos/producer"
)
public
class
NacosProducerController
{
public
class
NacosProducerController
{
@Value
(
"${user.name}"
)
private
String
nameInfo
;
/**
/**
* 获取配置的变量
* 获取配置的变量
*/
*/
@GetMapping
(
value
=
"/nameInfo"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
@GetMapping
(
value
=
"/nameInfo"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
public
Result
nameInfo
()
{
public
Result
nameInfo
()
{
return
Result
.
ok
(
nameInfo
);
return
Result
.
ok
();
}
}
}
}
...
...
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/controller/UserController.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.controller
;
import
com.kwan.springcloudalibaba.entity.User
;
import
com.kwan.springcloudalibaba.service.IUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 用户相关
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/12/19 16:08
*/
@Slf4j
@RestController
@RequestMapping
(
"/user"
)
public
class
UserController
{
@Autowired
private
IUserService
userService
;
@RequestMapping
(
value
=
"/all"
,
method
=
RequestMethod
.
GET
)
public
List
<
User
>
addAdvertise
()
{
log
.
info
(
"测试日志={}"
,
"success"
);
return
userService
.
getUsers
();
}
@RequestMapping
(
value
=
"/getUserById/{id}"
,
method
=
RequestMethod
.
GET
)
public
User
getUserById
(
@PathVariable
Integer
id
)
{
return
userService
.
getUserById
(
id
);
}
@RequestMapping
(
value
=
"/getUserByName"
,
method
=
RequestMethod
.
GET
)
public
User
getUserByName
(
@RequestParam
String
sex
)
{
return
userService
.
getUserByName
(
sex
);
}
}
\ No newline at end of file
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/entity/User.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@TableName
(
value
=
"user"
)
@AllArgsConstructor
@NoArgsConstructor
public
class
User
{
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
name
;
private
String
sex
;
}
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/mapper/UserMapper.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springcloudalibaba.entity.User
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* mapper文件
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/12/19 16:12
*/
@Mapper
public
interface
UserMapper
extends
BaseMapper
<
User
>
{
User
getUserByName
(
String
sex
);
}
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/service/IUserService.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springcloudalibaba.entity.User
;
import
java.util.List
;
public
interface
IUserService
extends
IService
<
User
>
{
/**
* 获取所有用户
*
* @return
*/
List
<
User
>
getUsers
();
/**
* 获取一个用户
*
* @return
*/
User
getUserById
(
Integer
id
);
/**
* 根据姓名查询
*
* @param sex
* @return
*/
User
getUserByName
(
String
sex
);
}
nacos-server-producer/src/main/java/com/kwan/springcloudalibaba/service/impl/UserServiceImpl.java
0 → 100644
浏览文件 @
f3c2e916
package
com.kwan.springcloudalibaba.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springcloudalibaba.entity.User
;
import
com.kwan.springcloudalibaba.mapper.UserMapper
;
import
com.kwan.springcloudalibaba.service.IUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Objects
;
@Service
public
class
UserServiceImpl
extends
ServiceImpl
<
UserMapper
,
User
>
implements
IUserService
{
@Autowired
private
UserMapper
userMapper
;
@Override
public
List
<
User
>
getUsers
()
{
return
userMapper
.
selectList
(
null
);
}
@Override
public
User
getUserById
(
Integer
id
)
{
return
userMapper
.
selectById
(
id
);
}
@Override
public
User
getUserByName
(
String
sex
)
{
User
userByName
=
userMapper
.
getUserByName
(
sex
);
if
(
Objects
.
isNull
(
userByName
))
{
userByName
=
new
User
();
}
return
userByName
;
}
}
\ No newline at end of file
nacos-server-producer/src/main/resources/bootstrap.yml
浏览文件 @
f3c2e916
#端口号
#端口号
server
:
server
:
port
:
9091
port
:
9091
#断电打开
management
:
endpoint
:
health
:
show-details
:
always
endpoints
:
jmx
:
exposure
:
include
:
'
*'
web
:
exposure
:
include
:
'
*'
#spring配置
#spring配置
spring
:
spring
:
application
:
application
:
...
@@ -28,5 +16,5 @@ spring:
...
@@ -28,5 +16,5 @@ spring:
server-addr
:
http://120.79.36.53:8848
#配置中心地址
server-addr
:
http://120.79.36.53:8848
#配置中心地址
file-extension
:
yaml
#文件类型
file-extension
:
yaml
#文件类型
group
:
DEV_GROUP
#组别
group
:
DEV_GROUP
#组别
namespace
:
e750dcd5-657b-489b-8d15-b7b71aa3e984
#命名空间
namespace
:
4cd9bd32-8f25-45cd-b919-df1a0df146e0
#命名空间
refresh-enabled
:
true
#默认自动刷新
refresh-enabled
:
true
#默认自动刷新
\ No newline at end of file
nacos-server-producer/src/main/resources/logback-spring.xml
0 → 100644
浏览文件 @
f3c2e916
<?xml version="1.0" encoding="UTF-8"?>
<configuration
debug=
"true"
>
<!-- 此xml在spring-boot-1.5.3.RELEASE.jar里 -->
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<!--控制台打印日志,不需要配置appender了-->
<include
resource=
"org/springframework/boot/logging/logback/console-appender.xml"
/>
<!-- 开启后可以通过jmx动态控制日志级别(springboot Admin的功能) -->
<!--<jmxConfigurator/>-->
<!--总日志-->
<appender
name=
"ALL-FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!--日志存放路径-->
<file>
../logs/springboot-mybatis.log
</file>
<encoder>
<!-- pattern节点,用来设置日志的输入格式 -->
<pattern>
%date [%level] [%thread] %logger{60} [%file : %line] %msg%n
</pattern>
<!--文件编码格式-->
<charset>
UTF-8
</charset>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->
<fileNamePattern>
../logs/springboot-mybatis.log.%d{yyyy-MM-dd}.log
</fileNamePattern>
<!-- 保留30天日志 -->
<maxHistory>
30
</maxHistory>
<!--文件最大存储-->
<totalSizeCap>
10GB
</totalSizeCap>
</rollingPolicy>
</appender>
<!--错误日志-->
<appender
name=
"ERROR-FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!--日志存放路径-->
<file>
../logs/error.log
</file>
<encoder>
<pattern>
%date [%level] [%thread] %logger{60} [%file : %line] %msg%n
</pattern>
<!--文件编码格式-->
<charset>
UTF-8
</charset>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->
<fileNamePattern>
../logs/error.%d{yyyy-MM-dd}.log
</fileNamePattern>
<!-- 保留30天日志 -->
<maxHistory>
30
</maxHistory>
<!--文件最大存储-->
<totalSizeCap>
10GB
</totalSizeCap>
</rollingPolicy>
<!-- 过滤日志 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<!-- 用于配置符合过滤条件的操作 -->
<onMatch>
ACCEPT
</onMatch>
<!-- 用于配置不符合过滤条件的操作 -->
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<logger
name=
"com.kwan.springbootkwan"
level=
"INFO"
/>
<root
level=
"INFO"
>
<!--控制台打印日志-->
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"ALL-FILE"
/>
<appender-ref
ref=
"ERROR-FILE"
/>
</root>
</configuration>
\ No newline at end of file
nacos-server-producer/src/main/resources/mapper/UserMapper.xml
0 → 100644
浏览文件 @
f3c2e916
<?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.kwan.springcloudalibaba.mapper.UserMapper"
>
<select
id=
"getUserByName"
resultType=
"com.kwan.springcloudalibaba.entity.User"
>
SELECT *
FROM user
WHERE sex = #{sex}
</select>
</mapper>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录