changing controller mapping

This commit is contained in:
eugenp 2017-06-17 14:04:38 +03:00
parent b11496ce26
commit 5a5f3fa459
6 changed files with 11 additions and 12 deletions

View File

@ -3,12 +3,11 @@ package com.baeldung.produceimage;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan("com.baeldung.produceimage") @ComponentScan("com.baeldung.produceimage")
public class Application { public class ImageApplication {
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(ImageApplication.class, args);
} }
} }

View File

@ -7,10 +7,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan("org.baeldung") @ComponentScan("org.baeldung")
public class Application extends WebMvcConfigurerAdapter { public class MainApplication extends WebMvcConfigurerAdapter {
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(MainApplication.class, args);
} }
} }

View File

@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
@Controller @Controller
@RequestMapping(value = "/myfoos") @RequestMapping(value = "/foos")
public class MyFooController { public class MyFooController {
private final Map<Long, Foo> myfoos; private final Map<Long, Foo> myfoos;

View File

@ -36,7 +36,7 @@ import com.google.common.base.Charsets;
public class RestTemplateBasicLiveTest { public class RestTemplateBasicLiveTest {
private RestTemplate restTemplate; private RestTemplate restTemplate;
private static final String fooResourceUrl = "http://localhost:" + APPLICATION_PORT + "/spring-rest/myfoos"; private static final String fooResourceUrl = "http://localhost:" + APPLICATION_PORT + "/spring-rest/foos";
@Before @Before
public void beforeTest() { public void beforeTest() {

View File

@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue;
public class TestRestTemplateBasicLiveTest { public class TestRestTemplateBasicLiveTest {
private RestTemplate restTemplate; private RestTemplate restTemplate;
private static final String FOO_RESOURCE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest/myfoos"; private static final String FOO_RESOURCE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest/foos";
private static final String URL_SECURED_BY_AUTHENTICATION = "http://httpbin.org/basic-auth/user/passwd"; private static final String URL_SECURED_BY_AUTHENTICATION = "http://httpbin.org/basic-auth/user/passwd";
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest"; private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";

View File

@ -14,7 +14,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
private AuthenticationManager authenticationManager; private AuthenticationManager authenticationManager;
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception { // @formatter:off
http.requestMatchers() http.requestMatchers()
.antMatchers("/login", "/oauth/authorize") .antMatchers("/login", "/oauth/authorize")
.and() .and()
@ -24,15 +24,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.and() .and()
.formLogin() .formLogin()
.permitAll(); .permitAll();
} } // @formatter:on
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception { // @formatter:off
auth.parentAuthenticationManager(authenticationManager) auth.parentAuthenticationManager(authenticationManager)
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("john") .withUser("john")
.password("123") .password("123")
.roles("USER"); .roles("USER");
} } // @formatter:on
} }