config : gradle com.ewerk.gradle.plugins.querydsl plugin 제거

Gradle Annotation processor를 사용하도록 설정 변경
dev
minuk926 3 years ago
parent a9c02807e4
commit 3e21f26348

@ -35,11 +35,12 @@ import java.io.IOException;
AppProperties.class
})
@ComponentScan(
nameGenerator = CustomBeanNameGenerator.class,
basePackages = {"com.xit.biz", "com.xit.core"},
excludeFilters = @ComponentScan.Filter(
type = FilterType.ASPECTJ,
pattern = {
"com.xit.._ignore..*"
"com.xit"
//"com..support.auth.jwt..*"
}
)
@ -66,9 +67,9 @@ public class Application { //WebApplicationInitializer {
// beanName Generator 등록 : API v1, v2 등으로 분류하는 경우
// Bean 이름 식별시 풀패키지 명으로 식별 하도록 함
CustomBeanNameGenerator beanNameGenerator = new CustomBeanNameGenerator();
beanNameGenerator.addBasePackages(BEAN_GEN_BASE_PACKAGE);
applicationBuilder.beanNameGenerator(beanNameGenerator);
//CustomBeanNameGenerator beanNameGenerator = new CustomBeanNameGenerator();
//beanNameGenerator.addBasePackages(BEAN_GEN_BASE_PACKAGE);
//applicationBuilder.beanNameGenerator(beanNameGenerator);
//TODO : 이벤트 실행 시점이 Application context 실행 이전인 경우 리스너 추가
//application.listeners(new xitCoreApplicationListner());

@ -0,0 +1,56 @@
package com.xit.core.config._ignore;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.lang.NonNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* ,
*
*
* .
*
* /v1/api, /v2/api
*/
public class CustomBeanNameGenerator implements BeanNameGenerator {
/**
* basePackages scaning beanGenerator
*/
private static final BeanNameGenerator DELEGATE = new AnnotationBeanNameGenerator();
/**
* VersioningBeanNameGenerator package
*/
private final List<String> basePackages = new ArrayList<>(
Arrays.asList("com.xit.biz", "com.xit.core")
);
@Override
public @NonNull String generateBeanName(@NonNull BeanDefinition definition, @NonNull BeanDefinitionRegistry registry) {
if(isTargetPackageBean(definition)) {
return getBeanName(definition);
}
return DELEGATE.generateBeanName(definition, registry);
}
private boolean isTargetPackageBean(BeanDefinition definition) {
String beanClassName = getBeanName(definition);
return basePackages.stream().anyMatch(beanClassName::startsWith);
}
private String getBeanName(BeanDefinition definition) {
return definition.getBeanClassName();
}
public void addBasePackages(String path) {
this.basePackages.add(path);
}
}

@ -0,0 +1,54 @@
package com.xit.core.config._ignore;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import java.util.Set;
/**
* <pre>
* ,
*
*
* .
*
* /v1/api, /v2/api
* </pre>
*/
public class CustomBeanNameGenerator2 implements BeanNameGenerator {
private final AnnotationBeanNameGenerator defaultNameGenerator = new AnnotationBeanNameGenerator();
@Override
public @NonNull String generateBeanName(@NonNull BeanDefinition definition, @NonNull BeanDefinitionRegistry registry) {
String beanName;
if (isService(definition)) {
beanName = getFullName((AnnotatedBeanDefinition) definition);
} else {
beanName = defaultNameGenerator.generateBeanName(definition, registry);
}
return beanName;
}
private String getFullName(final AnnotatedBeanDefinition definition) {
// 패키지를 포함한 전체 이름을 반환한다.
return definition.getMetadata().getClassName();
}
private boolean isService(final BeanDefinition definition) {
if (definition instanceof AnnotatedBeanDefinition) {
final Set<String> annotationTypes = ((AnnotatedBeanDefinition) definition).getMetadata()
.getAnnotationTypes();
return annotationTypes.stream()
.anyMatch(type -> type.equals(Service.class.getName()));
}
return false;
}
}

@ -1,6 +1,7 @@
package com.xit.core.config.database;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.xit.core.config.support.CustomBeanNameGenerator;
import com.xit.core.support.CamelCaseLinkedMap;
import com.xit.core.support.CamelCaseMap;
import com.xit.core.support.ObjectTypeHandler;
@ -54,6 +55,7 @@ import java.util.Map;
)
// Mybatis
@MapperScan(
nameGenerator = CustomBeanNameGenerator.class,
basePackages = DataSourceConfig.PACKAGE,
sqlSessionFactoryRef = "sqlSessionFactory"
)

@ -1,52 +1,21 @@
package com.xit.core.config.support;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.lang.NonNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Bean
* /v1/api, /v2/api
*/
public class CustomBeanNameGenerator implements BeanNameGenerator {
/**
* basePackages scaning beanGenerator
*/
private static final BeanNameGenerator DELEGATE = new AnnotationBeanNameGenerator();
/**
* VersioningBeanNameGenerator package
*/
private final List<String> basePackages = new ArrayList<>(
Arrays.asList("com.xit.biz", "com.xit.core")
);
@Override
public @NonNull String generateBeanName(@NonNull BeanDefinition definition, @NonNull BeanDefinitionRegistry registry) {
if(isTargetPackageBean(definition)) {
return getBeanName(definition);
}
return DELEGATE.generateBeanName(definition, registry);
}
private boolean isTargetPackageBean(BeanDefinition definition) {
String beanClassName = getBeanName(definition);
return basePackages.stream().anyMatch(beanClassName::startsWith);
}
private String getBeanName(BeanDefinition definition) {
return definition.getBeanClassName();
final String result;
result = generateFullBeanName((AnnotatedBeanDefinition)definition);
System.out.println(result);
return result;
}
public void addBasePackages(String path) {
this.basePackages.add(path);
private String generateFullBeanName(final AnnotatedBeanDefinition definition) {
return definition.getMetadata().getClassName();
}
}
Loading…
Cancel
Save