🎉 release 0.0.01
This commit is contained in:
parent
eef5a37018
commit
10c993f9d0
44
README.md
44
README.md
|
@ -6,6 +6,11 @@
|
|||
- [spring-boot-nebula-dependencies](spring-boot-nebula-dependencies) 统一依赖
|
||||
- [spring-boot-nebula-samples](spring-boot-nebula-samples) 使用示例
|
||||
- [spring-boot-nebula-web](spring-boot-nebula-web) web封装组件(包括统一异常返回,简化返回,自定义异常报警)
|
||||
- [spring-boot-nebula-web-common](spring-boot-nebula-web-common) web模块基础工具类
|
||||
- [spring-boot-nebula-distribute-lock](spring-boot-nebula-distribute-lock) 分布式锁
|
||||
|
||||
|
||||
|
||||
|
||||
> 每个模块可单独引用使用,不耦合
|
||||
|
||||
|
@ -76,4 +81,43 @@
|
|||
public String test(@GetTimestamp LocalDateTime time) {
|
||||
return time.toString();
|
||||
}
|
||||
```
|
||||
|
||||
# 依赖
|
||||
|
||||
- web
|
||||
```xml
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-web</artifactId>
|
||||
<version>0.0.01</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- 分布式锁
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
|
||||
<version>0.0.01</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- ddd聚合根组件
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-aggregate</artifactId>
|
||||
<version>0.0.01</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- mybatis-plus
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-mybatis-plus</artifactId>
|
||||
<version>0.0.01</version>
|
||||
</dependency>
|
||||
```
|
|
@ -18,11 +18,17 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
|
|
@ -72,6 +72,12 @@
|
|||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
@ -107,5 +113,151 @@
|
|||
|
||||
</dependencyManagement>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>weihubeats</name>
|
||||
<email>weihu@apche.org</email>
|
||||
<organization>https://weihubeats.blog.csdn.net/</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git@github.com:weihubeats/spring-boot-common.git</connection>
|
||||
<developerConnection>scm:git@github.com:weihubeats/spring-boot-common.git</developerConnection>
|
||||
<url>git@github.com:weihubeats/spring-boot-common.git</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Github Issue</system>
|
||||
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<inherited>true</inherited>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<inherited>true</inherited>
|
||||
<configuration>
|
||||
<forkCount>1</forkCount>
|
||||
<reuseForks>false</reuseForks>
|
||||
<!-- <skipTests>false</skipTests>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
|
||||
<additionalJOptions>
|
||||
<additionalJOption>-Xdoclint:none</additionalJOption>
|
||||
</additionalJOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Gpg Signature -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>${maven-gpg-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>flatten-maven-plugin</artifactId>
|
||||
<version>${flatten-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<updatePomFile>true</updatePomFile>
|
||||
<flattenMode>resolveCiFriendliesOnly</flattenMode>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>flatten</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>flatten</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>flatten.clean</id>
|
||||
<phase>clean</phase>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
</project>
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<version>0.0.01</version>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-nebula-mybatis</artifactId>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
</parent>
|
||||
<modules>
|
||||
<module>spring-boot-nebula-web-sample</module>
|
||||
<module>spring-boot-nebula-distribute-lock-sample</module>
|
||||
</modules>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -19,6 +20,7 @@
|
|||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-samples</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-nebula-distribute-lock-sample</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
GET localhost:8088/test
|
|
@ -0,0 +1,18 @@
|
|||
package com.nebula.distribute.lock.sample;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class DistributeLockApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
SpringApplication.run(DistributeLockApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.nebula.distribute.lock.sample.config;
|
||||
|
||||
import com.nebula.base.utils.DataUtils;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.codec.JsonJacksonCodec;
|
||||
import org.redisson.config.Config;
|
||||
import org.redisson.config.SingleServerConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author : wh
|
||||
* @date : 2024/3/16 11:02
|
||||
* @description:
|
||||
*/
|
||||
@Configuration
|
||||
public class RedissonConfig {
|
||||
|
||||
@Value("${redis.host}")
|
||||
private String redisLoginHost;
|
||||
@Value("${redis.port}")
|
||||
private Integer redisLoginPort;
|
||||
@Value("${redis.password}")
|
||||
private String redisLoginPassword;
|
||||
|
||||
|
||||
@Bean
|
||||
public RedissonClient redissonClient() {
|
||||
return createRedis(redisLoginHost, redisLoginPort, redisLoginPassword);
|
||||
}
|
||||
|
||||
private RedissonClient createRedis(String redisHost, Integer redisPort, String redisPassword) {
|
||||
Config config = new Config();
|
||||
SingleServerConfig singleServerConfig = config.useSingleServer();
|
||||
singleServerConfig.setAddress("redis://" + redisHost + ":" + redisPort + "");
|
||||
singleServerConfig.setDatabase(1);
|
||||
if (DataUtils.isNotEmpty(redisPassword)) {
|
||||
singleServerConfig.setPassword(redisPassword);
|
||||
}
|
||||
config.setCodec(new JsonJacksonCodec());
|
||||
return Redisson.create(config);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.nebula.distribute.lock.sample.controller;
|
||||
|
||||
import com.nebula.distribute.lock.sample.service.TestService;
|
||||
import com.nebula.web.boot.annotation.NebulaResponseBody;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author : wh
|
||||
* @date : 2023/8/2 10:28
|
||||
* @description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping()
|
||||
@RequiredArgsConstructor
|
||||
public class TestController {
|
||||
|
||||
private final TestService testServcie;
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
@NebulaResponseBody
|
||||
public String test() throws Exception{
|
||||
testServcie.test();
|
||||
return "小奏";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.nebula.distribute.lock.sample.service;
|
||||
|
||||
import com.nebula.distribute.lock.annotation.NebulaDistributedLock;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author : wh
|
||||
* @date : 2024/3/16 13:55
|
||||
* @description:
|
||||
*/
|
||||
@Service
|
||||
public class TestService {
|
||||
|
||||
@NebulaDistributedLock(lockName = "wh-test")
|
||||
public void test() {
|
||||
System.out.println("处理器请求中");
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println("请求处理完成");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: test
|
||||
application:
|
||||
name: web-test
|
||||
|
||||
server:
|
||||
port: 8088
|
||||
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: 123456
|
|
@ -9,10 +9,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
public class WebApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
SpringApplication.run(Application.class, args);
|
||||
SpringApplication.run(WebApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,5 @@ public class ActionTest {
|
|||
@Test
|
||||
public void test() {
|
||||
System.out.println("hahah");
|
||||
throw new RuntimeException("测试异常");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ public class NebulaPageTest {
|
|||
@Test
|
||||
public void testGetTotalCount() {
|
||||
System.out.println("hahah");
|
||||
throw new RuntimeException("测试异常");
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue