Skip to content

Commit eb8526c

Browse files
author
Grzegorz Piwowarek
committed
Fix java config
1 parent 96f4f73 commit eb8526c

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

‎spring-all/src/main/java/org/baeldung/controller/config/WebConfig.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@Configuration
1313
@EnableWebMvc
14-
@ComponentScan(basePackages= {"org.baledung.controller.controller","org.baledung.controller.config" })
14+
@ComponentScan(basePackages= {"org.baeldung.controller.controller","org.baeldung.controller.config" })
1515
public class WebConfig extends WebMvcConfigurerAdapter {
1616
@Override
1717
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {

‎spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationTest.java‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.baeldung.controller;
22

3-
import javax.servlet.ServletContext;
4-
3+
import com.fasterxml.jackson.databind.ObjectMapper;
54
import org.baeldung.controller.config.WebConfig;
65
import org.baeldung.controller.student.Student;
76
import org.junit.Assert;
@@ -11,31 +10,25 @@
1110
import org.springframework.beans.factory.annotation.Autowired;
1211
import org.springframework.test.context.ContextConfiguration;
1312
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
14-
import org.springframework.test.context.support.AnnotationConfigContextLoader;
13+
import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
1514
import org.springframework.test.context.web.WebAppConfiguration;
1615
import org.springframework.test.web.servlet.MockMvc;
1716
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
1817
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
1918
import org.springframework.web.context.WebApplicationContext;
2019
import org.springframework.web.servlet.ModelAndView;
2120

22-
import com.fasterxml.jackson.databind.ObjectMapper;
23-
2421

2522
@RunWith(SpringJUnit4ClassRunner.class)
2623
@WebAppConfiguration
27-
@ContextConfiguration(classes={WebConfig.class},loader=AnnotationConfigContextLoader.class )
24+
@ContextConfiguration(classes={WebConfig.class}, loader=AnnotationConfigWebContextLoader.class )
2825
public class ControllerAnnotationTest {
2926

30-
@Autowired
3127
private MockMvc mockMvc;
3228

3329
@Autowired
3430
private WebApplicationContext wac;
3531

36-
@Autowired
37-
private ServletContext servletContext;
38-
3932
private Student selectedStudent;
4033

4134
@Before

0 commit comments

Comments
 (0)