项目初始化
This commit is contained in:
parent
f79443f1c6
commit
4ee36699fe
@ -11,9 +11,6 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.plugins</groupId>
|
||||
<artifactId>spring-plugin-mapstruct</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
11
pom.xml
11
pom.xml
@ -8,11 +8,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>plugins-integration</name>
|
||||
<modules>
|
||||
<module>plugins-bom</module>
|
||||
<module>spring-plugin-mapstruct</module>
|
||||
<module>spring-plugin-test</module>
|
||||
</modules>
|
||||
|
||||
|
||||
<properties>
|
||||
<project-bom.version>1.0.0</project-bom.version>
|
||||
@ -88,6 +84,11 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>plugins-bom</module>
|
||||
<module>spring-plugin-test</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
|
||||
</repositories>
|
||||
|
||||
33
spring-plugin-mapstruct/.gitignore
vendored
33
spring-plugin-mapstruct/.gitignore
vendored
@ -1,33 +0,0 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -1,54 +0,0 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.plugins</groupId>
|
||||
<artifactId>plugins-integration</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>spring-plugin-mapstruct</artifactId>
|
||||
|
||||
<name>spring-plugin-mapstruct</name>
|
||||
<description>mapstruct 插件</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-processor</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@ -1 +0,0 @@
|
||||
spring.application.name=spring-plugin-mapstruct
|
||||
@ -10,15 +10,61 @@
|
||||
<artifactId>spring-plugin-test</artifactId>
|
||||
|
||||
<name>spring-plugin-test</name>
|
||||
<description>mapstruct 插件</description>
|
||||
<description>插件测试类</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.plugins</groupId>
|
||||
<artifactId>spring-plugin-mapstruct</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mapstruct-plus-->
|
||||
<dependency>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-processor</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.plugins.mapstruct;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.plugins.mapstruct.config;
|
||||
|
||||
|
||||
import io.github.linpeilie.utils.CollectionUtils;
|
||||
import io.github.linpeilie.utils.StrUtil;
|
||||
import org.mapstruct.Named;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@AutoConfiguration
|
||||
@Named("mapStructConvert")
|
||||
public class MapStructConvert {
|
||||
|
||||
@Named("stringToList")
|
||||
public List<String> stringToList(String str) {
|
||||
return StrUtil.isBlank(str)? Collections.emptyList():Arrays.asList(str.split(","));
|
||||
}
|
||||
|
||||
@Named("listToString")
|
||||
public String listToString(List<String> list) {
|
||||
return CollectionUtils.isEmpty(list)? "": String.join(",", list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
com.plugins.mapstruct.config.MapStructConvert
|
||||
@ -0,0 +1 @@
|
||||
spring.application.name=spring-plugin-test
|
||||
@ -0,0 +1 @@
|
||||
package com.plugins.mapstruct;
|
||||
@ -0,0 +1,17 @@
|
||||
package com.plugins.mapstruct.test;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@AutoMapper(target = B.class,reverseConvertGenerate = false)
|
||||
public class A {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String age;
|
||||
private String gender;
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.plugins.mapstruct.test;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@AutoMapper(target = A.class,reverseConvertGenerate = false)
|
||||
public class B {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String age;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.plugins.mapstruct.test;
|
||||
|
||||
import io.github.linpeilie.Converter;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
public class Run {
|
||||
|
||||
@Autowired
|
||||
Converter converter;
|
||||
|
||||
@Test
|
||||
void test1() {
|
||||
A a = new A().setId("1")
|
||||
.setName("<UNK>")
|
||||
.setAge("")
|
||||
.setGender("");
|
||||
B b = converter.convert(a, B.class);
|
||||
System.out.println(b.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user