JAVA全系列 教程
3762个小节阅读:7095.5k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
当我们工程中,有些重要的方法,没有添加在链路中,而我们又需要时,就可以添加自定义链路追踪的Span。
xxxxxxxxxx
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-trace</artifactId>
<version>8.5.0</version>
</dependency>
<!--数据库连接池 HikariCP-->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
</dependency>
xxxxxxxxxx
eureka:
client:
# 表示是否将自己注册到Eureka Server
register-with-eureka: true
# 示是否从Eureka Server获取注册的服务信息
fetch-registry: true
# Eureka Server地址
service-url:
defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka
instance:
instance-id: payment8003
prefer-ip-address: true
spring:
application:
# 设置应用名词
name: cloud-payment-provider
# 数据库配置
datasource:
name: sonice1024
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://192.168.66.101:3306/test?useSSL=false&useUnicode=true&characterEncoding=utf8&useSSL=false&useTimezone=true&serverTimezone=GMT%2B8
username: root
password: 123456
type: com.zaxxer.hikari.HikariDataSource
hikari:
minimum-idle: 3
auto-commit: true
idle-timeout: 10000
max-lifetime: 1800000
connection-timeout: 30000
connection-test-query: SELECT 1
server:
port: 8003
xxxxxxxxxx
/**
* 主启动类
*/
@EnableEurekaClient
@MapperScan("com.itbaizhan.mapper")
@SpringBootApplication
@Slf4j
public class PaymentMain8003 {
public static void main(String[] args) {
SpringApplication.run(PaymentMain8003.class,args);
log.info("********* 服务提供者启动成功 ******");
}
}
xxxxxxxxxx
@Data
public class User {
private Long id;
private String name;
private Integer age;
private String email;
}
xxxxxxxxxx
public interface UserMapper extends BaseMapper<User> {
}
xxxxxxxxxx
public interface UserService {
List<User> findByAllUser();
}
xxxxxxxxxx
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Trace
@Override
public List<User> findByAllUser() {
return userMapper.selectList(null);
}
}
xxxxxxxxxx
@RequestMapping("user")
@RestController
public class UserController {
@Autowired
private UserService userService;
@GetMapping("findByAll")
public List<User> findByAll(){
return userService.findByAllUser();
}
}