Skip to content

Commit 4cd0f32

Browse files
committed
fix #160
1 parent 5d50d92 commit 4cd0f32

File tree

10 files changed

+85
-13
lines changed

10 files changed

+85
-13
lines changed

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.10.20</version>
18+
<version>2.10.21</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>
@@ -235,6 +235,20 @@
235235
<compilerArgument>-Xlint:deprecation</compilerArgument>
236236
</configuration>
237237
</plugin>
238+
239+
<plugin>
240+
<groupId>org.apache.maven.plugins</groupId>
241+
<artifactId>maven-jar-plugin</artifactId>
242+
<version>${maven-jar-plugin.version}</version>
243+
<configuration>
244+
<archive>
245+
<manifestEntries>
246+
<Implementation-Version>${project.version}</Implementation-Version>
247+
<Implementation-Title>${project.name}</Implementation-Title>
248+
</manifestEntries>
249+
</archive>
250+
</configuration>
251+
</plugin>
238252
</plugins>
239253
</build>
240254

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.20</version>
9+
<version>2.10.21</version>
1010
</parent>
1111

1212
<name>springboot-starter-data-authorization</name>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>2.10.20</version>
8+
<version>2.10.21</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.20</version>
9+
<version>2.10.21</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.20</version>
9+
<version>2.10.21</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter-security/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
88
import org.springframework.boot.test.context.SpringBootTest;
99
import org.springframework.http.MediaType;
10+
import org.springframework.security.crypto.password.PasswordEncoder;
1011
import org.springframework.test.web.servlet.MockMvc;
1112
import org.springframework.test.web.servlet.MvcResult;
1213
import org.springframework.util.StringUtils;
1314

1415
import java.nio.charset.StandardCharsets;
1516

16-
import static org.junit.jupiter.api.Assertions.assertEquals;
17-
import static org.junit.jupiter.api.Assertions.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.*;
1818
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1919
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
2020
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -27,6 +27,20 @@ public class SecurityJwtApplicationTest {
2727
@Autowired
2828
private MockMvc mockMvc;
2929

30+
31+
@Autowired
32+
private PasswordEncoder passwordEncoder;
33+
34+
35+
@Test
36+
void encode(){
37+
String pwd1 = passwordEncoder.encode("123456");
38+
String pwd2 = passwordEncoder.encode("123456");
39+
System.out.println(pwd1);
40+
System.out.println(pwd2);
41+
assertNotEquals(pwd1,pwd2);
42+
}
43+
3044
@Test
3145
void login() throws Exception {
3246
JSONObject json = new JSONObject();
@@ -37,6 +51,7 @@ void login() throws Exception {
3751
.contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
3852
}
3953

54+
4055
@Test
4156
void loginError() throws Exception {
4257
JSONObject json = new JSONObject();

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.10.20</version>
8+
<version>2.10.21</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
package com.codingapi.springboot.framework;
22

3+
import com.codingapi.springboot.framework.utils.VersionUtils;
4+
import org.springframework.beans.factory.InitializingBean;
35
import org.springframework.context.annotation.Configuration;
46

57
@Configuration
6-
public class AutoConfiguration {
8+
public class AutoConfiguration implements InitializingBean {
79

10+
@Override
11+
public void afterPropertiesSet() throws Exception {
12+
String version = VersionUtils.getDriverVersion();
13+
this.printBanner(version);
14+
}
15+
16+
public void printBanner(String version) {
17+
System.out.println("------------------------------------------------------");
18+
System.out.println("\t\tCodingApi SpringBoot-Starter " + version);
19+
System.out.println("------------------------------------------------------");
20+
}
821
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.codingapi.springboot.framework.utils;
2+
3+
import java.io.InputStream;
4+
import java.util.jar.Attributes;
5+
import java.util.jar.Manifest;
6+
7+
public class VersionUtils {
8+
9+
public static String getJarVersion(Class<?> clazz) {
10+
try {
11+
String classPath = clazz.getResource(clazz.getSimpleName() + ".class").toString();
12+
if (!classPath.startsWith("jar")) {
13+
// 不是从 jar 启动的
14+
return "DEV";
15+
}
16+
17+
String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
18+
try (InputStream inputStream = new java.net.URL(manifestPath).openStream()) {
19+
Manifest manifest = new Manifest(inputStream);
20+
Attributes attributes = manifest.getMainAttributes();
21+
return attributes.getValue("Implementation-Version");
22+
}
23+
} catch (Exception e) {
24+
return "UNKNOWN";
25+
}
26+
}
27+
28+
29+
public static String getDriverVersion(){
30+
return VersionUtils.getJarVersion(VersionUtils.class);
31+
}
32+
33+
34+
}

springboot-starter/src/main/resources/META-INF/banner.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)