Skip to content

Commit 45a3bde

Browse files
After Hell of update, finally the project runs, Yahooo!!! Version compatibility is a big issue.
1 parent 581c864 commit 45a3bde

File tree

9 files changed

+88
-31
lines changed

9 files changed

+88
-31
lines changed

pom.xml

+21-12
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
<groupId>org.springframework.boot</groupId>
1010
<artifactId>spring-boot-starter-parent</artifactId>
1111
<version>2.1.1.RELEASE</version>
12-
<relativePath /> <!-- lookup parent from repository -->
12+
<relativePath/> <!-- lookup parent from repository -->
1313
</parent>
1414

1515
<properties>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1717
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1818
<java.version>11</java.version>
19+
<jjwt.version>0.9.1</jjwt.version>
20+
<bucket4j-core.version>4.10.0</bucket4j-core.version>
21+
<springfox-swagger2.version>2.8.0</springfox-swagger2.version>
22+
<modelmapper.version>2.4.4</modelmapper.version>
23+
<guava.version>18.0</guava.version>
24+
<jakarta.xml.bind-api.version>2.3.2</jakarta.xml.bind-api.version>
1925
</properties>
2026

2127
<dependencies>
@@ -34,7 +40,7 @@
3440
<dependency>
3541
<groupId>io.jsonwebtoken</groupId>
3642
<artifactId>jjwt</artifactId>
37-
<version>0.9.1</version>
43+
<version>${jjwt.version}</version>
3844
</dependency>
3945
<dependency>
4046
<groupId>org.springframework.boot</groupId>
@@ -47,27 +53,30 @@
4753
<dependency>
4854
<groupId>com.github.vladimir-bukhtoyarov</groupId>
4955
<artifactId>bucket4j-core</artifactId>
50-
<version>4.10.0</version>
56+
<version>${bucket4j-core.version}</version>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>io.springfox</groupId>
61+
<artifactId>springfox-swagger2</artifactId>
62+
<version>${springfox-swagger2.version}</version>
5163
</dependency>
5264
<dependency>
5365
<groupId>io.springfox</groupId>
54-
<artifactId>springfox-boot-starter</artifactId>
55-
<version>3.0.0</version>
66+
<artifactId>springfox-swagger-ui</artifactId>
67+
<version>${springfox-swagger2.version}</version>
5668
</dependency>
5769
<dependency>
5870
<groupId>org.modelmapper</groupId>
5971
<artifactId>modelmapper</artifactId>
60-
<version>2.4.4</version>
72+
<version>${modelmapper.version}</version>
6173
</dependency>
62-
<dependency>
63-
<groupId>org.springframework</groupId>
64-
<artifactId>spring-context-support</artifactId>
65-
</dependency>
74+
6675

6776
<dependency>
6877
<groupId>com.google.guava</groupId>
6978
<artifactId>guava</artifactId>
70-
<version>19.0</version>
79+
<version>${guava.version}</version>
7180
</dependency>
7281
<dependency>
7382
<groupId>com.h2database</groupId>
@@ -79,7 +88,7 @@
7988
<dependency>
8089
<groupId>jakarta.xml.bind</groupId>
8190
<artifactId>jakarta.xml.bind-api</artifactId>
82-
<version>2.3.2</version>
91+
<version>${jakarta.xml.bind-api.version}</version>
8392
</dependency>
8493
</dependencies>
8594

src/main/java/com/learning/config/SwaggerConfig.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.learning.config;
22

3+
import com.google.common.base.Predicates;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56
import springfox.documentation.builders.PathSelectors;
@@ -28,7 +29,7 @@ public Docket api() {
2829
return new Docket(DocumentationType.SWAGGER_2)
2930
.select()
3031
.apis(RequestHandlerSelectors.any())
31-
.paths(PathSelectors.regex("/error").negate())
32+
.paths(Predicates.not(PathSelectors.regex("/error")))
3233
.build()
3334
.useDefaultResponseMessages(false)
3435
.securitySchemes(Collections.singletonList(apiKey()))

src/main/java/com/learning/config/WebSecurityConfig.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.learning.config;
22

33
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Qualifier;
45
import org.springframework.context.annotation.Bean;
56
import org.springframework.context.annotation.Configuration;
67
import org.springframework.security.authentication.AuthenticationManager;
@@ -27,8 +28,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
2728
@Autowired
2829
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
2930

31+
@Qualifier("userDetailsServiceImpl")
3032
@Autowired
31-
private UserDetailsService jwtUserDetailsService;
33+
private UserDetailsService userDetailsService;
3234

3335
@Autowired
3436
private JwtRequestFilter jwtRequestFilter;
@@ -38,7 +40,7 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception
3840
// configure AuthenticationManager so that it knows from where to load
3941
// user for matching credentials
4042
// Use BCryptPasswordEncoder
41-
auth.userDetailsService(jwtUserDetailsService).passwordEncoder(passwordEncoder());
43+
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
4244
}
4345

4446
@Bean

src/main/java/com/learning/exception/ErrorResponse.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
public class ErrorResponse {
66

7-
@ApiModelProperty(position = 0)
7+
@ApiModelProperty(value = "Error Status",
8+
name = "status",
9+
dataType = "String",
10+
example = "")
811
private String status;
9-
@ApiModelProperty(position = 1)
12+
@ApiModelProperty(value = "Message",
13+
name = "message",
14+
dataType = "String",
15+
example = "")
1016
private String message;
11-
@ApiModelProperty(position = 2)
17+
@ApiModelProperty(value = "Details",
18+
name = "details",
19+
dataType = "String",
20+
example = "")
1221
private String details;
1322

1423
/**

src/main/java/com/learning/payload/request/LoginRequest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77

88
public class LoginRequest {
99
@NotBlank(message = "Username can't be blank")
10-
@ApiModelProperty(position = 0)
10+
@ApiModelProperty(value = "Username",
11+
name = "username",
12+
dataType = "String",
13+
example = "")
1114
private String username;
1215

1316
@NotBlank(message = "Password can't be blank")
14-
@ApiModelProperty(position = 1)
17+
@ApiModelProperty(value = "Password",
18+
name = "password",
19+
dataType = "String",
20+
example = "")
1521
private String password;
1622

1723
public String getUsername() {

src/main/java/com/learning/payload/request/SignupRequest.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,33 @@
1010
public class SignupRequest {
1111
@NotBlank
1212
@Size(min = 3, max = 20)
13-
@ApiModelProperty(position = 0)
13+
@ApiModelProperty(value = "Username",
14+
name = "username",
15+
dataType = "String",
16+
example = "")
1417
private String username;
1518

1619
@NotBlank
1720
@Size(max = 50)
1821
@Email
19-
@ApiModelProperty(position = 1)
22+
@ApiModelProperty(value = "User email",
23+
name = "email",
24+
dataType = "String",
25+
example = "")
2026
private String email;
2127

22-
@ApiModelProperty(position = 2)
28+
@ApiModelProperty(value = "Roles",
29+
name = "roles",
30+
dataType = "List<String>",
31+
example = "")
2332
private Set<String> role;
2433

2534
@NotBlank
2635
@Size(min = 6, max = 40)
27-
@ApiModelProperty(position = 3)
36+
@ApiModelProperty(value = "Password",
37+
name = "password",
38+
dataType = "String",
39+
example = "")
2840
private String password;
2941

3042
public String getUsername() {

src/main/java/com/learning/payload/response/JwtResponse.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55
import java.util.List;
66

77
public class JwtResponse {
8-
@ApiModelProperty(position = 0)
8+
@ApiModelProperty(value = "JWT Token",
9+
name = "token",
10+
dataType = "String",
11+
example = "")
912
private String token;
1013
private String type = "Bearer";
11-
@ApiModelProperty(position = 1)
14+
@ApiModelProperty(value = "User ID",
15+
name = "id",
16+
dataType = "Long",
17+
example = "")
1218
private Long id;
13-
@ApiModelProperty(position = 2)
19+
@ApiModelProperty(value = "Username",
20+
name = "username",
21+
dataType = "String",
22+
example = "")
1423
private String username;
15-
@ApiModelProperty(position = 3)
24+
@ApiModelProperty(value = "User email",
25+
name = "email",
26+
dataType = "String",
27+
example = "")
1628
private String email;
17-
@ApiModelProperty(position = 4)
29+
@ApiModelProperty(value = "Roles",
30+
name = "roles",
31+
dataType = "List<String>",
32+
example = "")
1833
private List<String> roles;
1934

2035
public JwtResponse(String accessToken, Long id, String username, String email, List<String> roles) {

src/main/java/com/learning/payload/response/MessageResponse.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import io.swagger.annotations.ApiModelProperty;
44

55
public class MessageResponse {
6-
@ApiModelProperty(position = 0)
6+
@ApiModelProperty(value = "Response message",
7+
name = "message",
8+
dataType = "String",
9+
example = "User registration successful")
710
private String message;
811

912
public MessageResponse(String message) {

src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spring.jpa.defer-datasource-initialization=true
1919
my.app.jwt.secret=learning
2020
my.app.jwtExpirationMs= 6000000
2121

22-
logging.level.root=debug
22+
#logging.level.root=debug
2323

2424

2525
#jwt.get.token.uri=/authenticate

0 commit comments

Comments
 (0)