Skip to content

Commit

Permalink
精简依赖包
Browse files Browse the repository at this point in the history
  • Loading branch information
YunlongChen committed Jan 5, 2024
1 parent b54c413 commit c70a986
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 84 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@

<sentinel.version>1.7.2</sentinel.version>
<zhangli.common.version>1.0.0.RELEASE</zhangli.common.version>
<guava.version>31.1-jre</guava.version>
<guava.version>33.0.0-jre</guava.version>
<lombok.version>1.18.24</lombok.version>
<hutool.version>5.8.22</hutool.version>
<hutool.version>5.8.24</hutool.version>
<authing.version>3.0.14</authing.version>
<swagger.version>2.2.8</swagger.version>
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
Expand Down
16 changes: 12 additions & 4 deletions qing-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.apache.tomcat.embed</groupId>-->
<!-- <artifactId>tomcat-embed-core</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -100,8 +108,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package cn.chenyunlong.common.enums;

import com.google.common.collect.Maps;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
Expand All @@ -22,6 +17,12 @@
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Created by taoli on 2022/12/10.
* gitee : <a href="https://gitee.com/litao851025/lego">...</a>
Expand All @@ -30,7 +31,7 @@
@Component
@Slf4j
@RequiredArgsConstructor
public class CommonEnumRegistry {
public class CommonEnumRegistry implements InitializingBean {
private static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
private static final String BASE__ENUM_CLASS_NAME = CommonEnum.class.getName();

Expand All @@ -45,28 +46,38 @@ public class CommonEnumRegistry {

private final ResourceLoader resourceLoader;


private String toPackage(String basePackage) {
String result = basePackage.replace(".", "/");
return result + "/";
}

private String convertKeyFromClassName(String className) {
return Character.toLowerCase(className.charAt(0)) + className.substring(1);
}

/**
* 初始化枚举字典
*/
@PostConstruct
public void initDict() {
@Override
public void afterPropertiesSet() throws Exception {
if (StringUtils.isEmpty(basePackage)) {
return;
}
ResourcePatternResolver resourcePatternResolver =
ResourcePatternUtils.getResourcePatternResolver(this.resourceLoader);
ResourcePatternUtils.getResourcePatternResolver(this.resourceLoader);
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
try {
String pkg = toPackage(this.basePackage);
// 对 basePackage 包进行扫描
String packageSearchPath =
ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + pkg + DEFAULT_RESOURCE_PATTERN;
ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + pkg + DEFAULT_RESOURCE_PATTERN;
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
for (Resource resource : resources) {
if (resource.isReadable()) {
try {
MetadataReader metadataReader =
metadataReaderFactory.getMetadataReader(resource);
metadataReaderFactory.getMetadataReader(resource);
ClassMetadata classMetadata = metadataReader.getClassMetadata();

String[] interfaceNames = classMetadata.getInterfaceNames();
Expand All @@ -79,9 +90,9 @@ public void initDict() {
if (cls.isEnum() && CommonEnum.class.isAssignableFrom(cls)) {
Object[] enumConstants = cls.getEnumConstants();
List<CommonEnum> commonEnums = Arrays.stream(enumConstants)
.filter(e -> e instanceof CommonEnum)
.map(e -> (CommonEnum) e)
.collect(Collectors.toList());
.filter(e -> e instanceof CommonEnum)
.map(e -> (CommonEnum) e)
.collect(Collectors.toList());

String key = convertKeyFromClassName(cls.getSimpleName());

Expand All @@ -98,13 +109,4 @@ public void initDict() {
log.error("failed to load dict by auto register", e);
}
}

private String toPackage(String basePackage) {
String result = basePackage.replace(".", "/");
return result + "/";
}

private String convertKeyFromClassName(String className) {
return Character.toLowerCase(className.charAt(0)) + className.substring(1);
}
}

This file was deleted.

6 changes: 6 additions & 0 deletions qing-infrastructure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@
<groupId>org.springframework.statemachine</groupId>
<artifactId>spring-statemachine-core</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
import cn.hutool.json.JSONUtil;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.*;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
Expand All @@ -37,6 +34,10 @@
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.*;

/**
* 统一日志处理切面
*
Expand Down

0 comments on commit c70a986

Please sign in to comment.