release branch 1.1.0

This commit is contained in:
binbin.hou
2022-12-07 21:00:45 +08:00
parent 27a931ae77
commit c45f6b53a0
27 changed files with 444 additions and 78 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>lock</artifactId>
<groupId>com.github.houbb</groupId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -30,6 +30,23 @@
<groupId>com.github.houbb</groupId>
<artifactId>test-spring</artifactId>
</dependency>
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>slf4j-common</artifactId>
<version>1.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.11</version>
</dependency>
</dependencies>
</project>

View File

@@ -11,12 +11,16 @@ import org.springframework.stereotype.Service;
@Service
public class UserService {
public String rawUserName(Long userId) {
return userId+"-name";
}
@Lock
public String queryUserName(Long userId) {
return userId+"-name";
}
@Lock(value = "#arg0.name")
@Lock(value = "#user.name")
public void queryUserName2(User user) {
System.out.println("user: " + user.toString());
}

View File

@@ -0,0 +1,41 @@
package com.github.houbb.lock.test.spring;
import com.github.houbb.lock.core.bs.LockBs;
import com.github.houbb.lock.test.config.SpringConfig;
import com.github.houbb.lock.test.model.User;
import com.github.houbb.lock.test.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author binbin.hou
* @since 1.0.0
*/
@ContextConfiguration(classes = SpringConfig.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringServiceRawTest {
@Autowired
private UserService userService;
@Autowired
private LockBs lockBs;
@Test
public void queryLogTest() {
final String key = "name";
try {
lockBs.tryLock(key);
final String value = userService.rawUserName(1L);
} catch (Exception exception) {
throw new RuntimeException(exception);
} finally {
lockBs.unlock(key);
}
}
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 /app/sv/logs -->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<!--com.github.houbb 包路径 additivity 表示是否 想上层传递)-->
<logger name="com.github.houbb.lock" level="INFO" additivity="true">
</logger>
<!-- 日志输出级别-->
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>