diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml index 8f8e3907..8218edef 100644 --- a/example/example-app/example-app-cmd-domain/pom.xml +++ b/example/example-app/example-app-cmd-domain/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml index e45976bd..eb40dd1d 100644 --- a/example/example-app/example-app-cmd-meta/pom.xml +++ b/example/example-app/example-app-cmd-meta/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml index 2ef5e9c6..446b4663 100644 --- a/example/example-app/example-app-query/pom.xml +++ b/example/example-app/example-app-query/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml index 2ecec0d3..31e3ca2a 100644 --- a/example/example-app/pom.xml +++ b/example/example-app/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.20 + 3.4.21 ../pom.xml pom diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml index 9c5efe8a..8ebb1b03 100644 --- a/example/example-domain/example-domain-leave/pom.xml +++ b/example/example-domain/example-domain-leave/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml index dabbc0ce..204570a6 100644 --- a/example/example-domain/example-domain-user/pom.xml +++ b/example/example-domain/example-domain-user/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml index 0f1edc12..9f28c813 100644 --- a/example/example-domain/pom.xml +++ b/example/example-domain/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-example - 3.4.20 + 3.4.21 ../pom.xml 4.0.0 diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml index 6613d337..d8e07b22 100644 --- a/example/example-infra/example-infra-flow/pom.xml +++ b/example/example-infra/example-infra-flow/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml index f0be2c54..03a38af9 100644 --- a/example/example-infra/example-infra-jpa/pom.xml +++ b/example/example-infra/example-infra-jpa/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml index 54ff3771..1c75eb51 100644 --- a/example/example-infra/example-infra-security/pom.xml +++ b/example/example-infra/example-infra-security/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-infra - 3.4.20 + 3.4.21 ../pom.xml diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml index 290856e8..82bf9418 100644 --- a/example/example-infra/pom.xml +++ b/example/example-infra/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.20 + 3.4.21 ../pom.xml pom diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml index 3270d106..1de3a6b0 100644 --- a/example/example-interface/pom.xml +++ b/example/example-interface/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.20 + 3.4.21 example-interface diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml index 78714d92..e3c8b7c6 100644 --- a/example/example-server/pom.xml +++ b/example/example-server/pom.xml @@ -5,7 +5,7 @@ springboot-example com.codingapi.springboot - 3.4.20 + 3.4.21 4.0.0 diff --git a/example/example-server/src/main/resources/application.properties b/example/example-server/src/main/resources/application.properties index edd6c953..314b78fb 100644 --- a/example/example-server/src/main/resources/application.properties +++ b/example/example-server/src/main/resources/application.properties @@ -1,16 +1,16 @@ server.port=8090 application.version=@project.version@ -#spring.datasource.driver-class-name=org.h2.Driver -#spring.datasource.url=jdbc:h2:file:./example.db -#spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:file:./example.db +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.username=root -spring.datasource.password=admin123 -spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +#spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +#spring.datasource.username=root +#spring.datasource.password=admin123 +#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true diff --git a/example/pom.xml b/example/pom.xml index 010a397d..3368f943 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ springboot-example - 3.4.20 + 3.4.21 springboot-example springboot-example project for Spring Boot diff --git a/pom.xml b/pom.xml index 3523a56e..f5b20814 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.codingapi.springboot springboot-parent - 3.4.20 + 3.4.21 https://github.com/codingapi/springboot-framewrok springboot-parent @@ -230,6 +230,20 @@ -Xlint:deprecation + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + + ${project.version} + ${project.name} + + + + diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml index 3431426b..7226b96b 100644 --- a/springboot-starter-data-authorization/pom.xml +++ b/springboot-starter-data-authorization/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-parent - 3.4.20 + 3.4.21 springboot-starter-data-authorization diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml index c98127a8..6f31e7ad 100644 --- a/springboot-starter-data-fast/pom.xml +++ b/springboot-starter-data-fast/pom.xml @@ -5,7 +5,7 @@ springboot-parent com.codingapi.springboot - 3.4.20 + 3.4.21 4.0.0 diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml index 8e977bd5..ccba4930 100644 --- a/springboot-starter-flow/pom.xml +++ b/springboot-starter-flow/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.20 + 3.4.21 springboot-starter-flow diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml index 3d341dd7..98062cf8 100644 --- a/springboot-starter-security/pom.xml +++ b/springboot-starter-security/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.20 + 3.4.21 springboot-starter-security diff --git a/springboot-starter-security/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java b/springboot-starter-security/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java index 3872eadc..8aa9d6c8 100644 --- a/springboot-starter-security/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java +++ b/springboot-starter-security/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java @@ -7,14 +7,14 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.StringUtils; import java.nio.charset.StandardCharsets; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -27,6 +27,18 @@ public class SecurityJwtApplicationTest { @Autowired private MockMvc mockMvc; + @Autowired + private PasswordEncoder passwordEncoder; + + @Test + void encode(){ + String pwd1 = passwordEncoder.encode("123456"); + String pwd2 = passwordEncoder.encode("123456"); + System.out.println(pwd1); + System.out.println(pwd2); + assertNotEquals(pwd1,pwd2); + } + @Test void login() throws Exception { JSONObject json = new JSONObject(); diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml index d9d98d98..ed1494fa 100644 --- a/springboot-starter/pom.xml +++ b/springboot-starter/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-parent - 3.4.20 + 3.4.21 springboot-starter diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/AutoConfiguration.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/AutoConfiguration.java index 2cfc0ae1..27fbca1c 100644 --- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/AutoConfiguration.java +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/AutoConfiguration.java @@ -1,8 +1,21 @@ package com.codingapi.springboot.framework; +import com.codingapi.springboot.framework.utils.VersionUtils; +import org.springframework.beans.factory.InitializingBean; import org.springframework.context.annotation.Configuration; @Configuration -public class AutoConfiguration { +public class AutoConfiguration implements InitializingBean { + @Override + public void afterPropertiesSet() throws Exception { + String version = VersionUtils.getDriverVersion(); + this.printBanner(version); + } + + public void printBanner(String version) { + System.out.println("------------------------------------------------------"); + System.out.println("\t\tCodingApi SpringBoot-Starter " + version); + System.out.println("------------------------------------------------------"); + } } diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/utils/VersionUtils.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/utils/VersionUtils.java new file mode 100644 index 00000000..4c1cedb7 --- /dev/null +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/utils/VersionUtils.java @@ -0,0 +1,34 @@ +package com.codingapi.springboot.framework.utils; + +import java.io.InputStream; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +public class VersionUtils { + + public static String getJarVersion(Class clazz) { + try { + String classPath = clazz.getResource(clazz.getSimpleName() + ".class").toString(); + if (!classPath.startsWith("jar")) { + // 不是从 jar 启动的 + return "DEV"; + } + + String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF"; + try (InputStream inputStream = new java.net.URL(manifestPath).openStream()) { + Manifest manifest = new Manifest(inputStream); + Attributes attributes = manifest.getMainAttributes(); + return attributes.getValue("Implementation-Version"); + } + } catch (Exception e) { + return "UNKNOWN"; + } + } + + + public static String getDriverVersion(){ + return VersionUtils.getJarVersion(VersionUtils.class); + } + + +} diff --git a/springboot-starter/src/main/resources/banner.txt b/springboot-starter/src/main/resources/banner.txt deleted file mode 100644 index 4cbc0603..00000000 --- a/springboot-starter/src/main/resources/banner.txt +++ /dev/null @@ -1,4 +0,0 @@ ------------------------------------------------------- -CodingApi SpringBoot-Starter 3.4.20 -springboot version (${spring-boot.version}) -------------------------------------------------------