File tree Expand file tree Collapse file tree 6 files changed +13
-22
lines changed
main/java/com/naturalprogrammer/spring/tutorial
test/java/com/naturalprogrammer/spring/tutorial Expand file tree Collapse file tree 6 files changed +13
-22
lines changed Original file line number Diff line number Diff line change 1414 <parent >
1515 <groupId >org.springframework.boot</groupId >
1616 <artifactId >spring-boot-starter-parent</artifactId >
17- <version >1.3.2 .RELEASE</version >
17+ <version >1.4.0 .RELEASE</version >
1818 <relativePath /> <!-- lookup parent from repository -->
1919 </parent >
2020
Original file line number Diff line number Diff line change 55import org .springframework .context .annotation .Bean ;
66import org .springframework .context .annotation .Configuration ;
77import org .springframework .http .HttpMethod ;
8- import org .springframework .security .config .annotation .authentication .builders .AuthenticationManagerBuilder ;
98import org .springframework .security .config .annotation .method .configuration .EnableGlobalMethodSecurity ;
109import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
1110import org .springframework .security .config .annotation .web .configuration .WebSecurityConfigurerAdapter ;
@@ -29,24 +28,18 @@ public PasswordEncoder passwordEncoder() {
2928 return new BCryptPasswordEncoder ();
3029 }
3130
32- @ Override
33- protected void configure (AuthenticationManagerBuilder builder ) throws Exception {
34-
35- builder .userDetailsService (userDetailsService ).passwordEncoder (passwordEncoder ());
36- }
37-
3831 @ Override
3932 protected void configure (HttpSecurity http ) throws Exception {
4033
4134 http
4235 .authorizeRequests ()
43- .antMatchers (HttpMethod .GET ,
36+ .mvcMatchers (HttpMethod .GET ,
4437 "/" ).permitAll ()
45- .antMatchers (
38+ .mvcMatchers (
4639 "/signup" ,
4740 "/forgot-password" ,
4841 "/reset-password/*" ).permitAll ()
49- .antMatchers (HttpMethod .GET , "/admin/**" ).hasRole ("ADMIN" )
42+ .mvcMatchers (HttpMethod .GET , "/admin/**" ).hasRole ("ADMIN" )
5043 .anyRequest ().authenticated ()
5144 .and ()
5245 .formLogin ()
Original file line number Diff line number Diff line change 22
33import javax .mail .MessagingException ;
44
5- import org .springframework .beans .factory .annotation .Autowired ;
65import org .springframework .web .bind .annotation .RequestMapping ;
76import org .springframework .web .bind .annotation .RestController ;
87
@@ -13,7 +12,6 @@ public class MailController {
1312
1413 private MailSender mailSender ;
1514
16- @ Autowired
1715 public MailController (MailSender mailSender ) {
1816 this .mailSender = mailSender ;
1917 }
Original file line number Diff line number Diff line change 55import org .springframework .ui .Model ;
66import org .springframework .validation .BindingResult ;
77import org .springframework .validation .annotation .Validated ;
8+ import org .springframework .web .bind .annotation .GetMapping ;
9+ import org .springframework .web .bind .annotation .PostMapping ;
810import org .springframework .web .bind .annotation .RequestMapping ;
9- import org .springframework .web .bind .annotation .RequestMethod ;
1011import org .springframework .web .servlet .mvc .support .RedirectAttributes ;
1112
1213import com .naturalprogrammer .spring .tutorial .domain .User ;
@@ -20,14 +21,14 @@ public class SignupController {
2021 @ Autowired
2122 private UserService userService ;
2223
23- @ RequestMapping ( method = RequestMethod . GET )
24+ @ GetMapping
2425 public String signup (Model model ) {
2526
2627 model .addAttribute (new User ());
2728 return "signup" ;
2829 }
2930
30- @ RequestMapping ( method = RequestMethod . POST )
31+ @ PostMapping
3132 public String doSignup (@ Validated User user ,
3233 BindingResult result ,
3334 RedirectAttributes redirectAttributes ) {
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ public static enum Role {
3939 private long id ;
4040
4141 @ UniqueEmail
42+ @ Column (nullable = false , length = 250 )
4243 private String email ;
4344
4445 @ NotBlank
Original file line number Diff line number Diff line change 22
33import org .junit .Test ;
44import org .junit .runner .RunWith ;
5- import org .springframework .boot .test .SpringApplicationConfiguration ;
6- import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
7- import org .springframework .test .context .web .WebAppConfiguration ;
5+ import org .springframework .boot .test .context .SpringBootTest ;
6+ import org .springframework .test .context .junit4 .SpringRunner ;
87
9- @ RunWith (SpringJUnit4ClassRunner .class )
10- @ SpringApplicationConfiguration (classes = NpSpringTutorialApplication .class )
11- @ WebAppConfiguration
8+ @ RunWith (SpringRunner .class )
9+ @ SpringBootTest
1210public class NpSpringTutorialApplicationTests {
1311
1412 @ Test
You can’t perform that action at this time.
0 commit comments