/
SpringMockMvcConfiguration.java
78 lines (67 loc) · 3.49 KB
/
SpringMockMvcConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* SpringMockMvcConfiguration.java
*
* Created on 2018-05-14, 7:02
*/
package com.marcnuri.demo.springmockmvc;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
* Created by Marc Nuri <marc@marcnuri.com> on 2018-05-14.
*/
@Configuration
@EnableWebMvc
@EnableConfigurationProperties(ServerProperties.class)
@ComponentScan(value = "com.marcnuri.demo.springmockmvc",
excludeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Test.*"))
public class SpringMockMvcConfiguration implements WebMvcConfigurer {
//**************************************************************************************************
// Fields
//**************************************************************************************************
//**************************************************************************************************
// Constructors
//**************************************************************************************************
//**************************************************************************************************
// Abstract Methods
//**************************************************************************************************
//**************************************************************************************************
// Overridden Methods
//**************************************************************************************************
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/index.html").addResourceLocations("/index.html");
}
//**************************************************************************************************
// Other Methods
//**************************************************************************************************
/**
* Resolves any .html file as a view (used in 'forward:' controllers)
*
* @return InternalResourceViewResolver with the specified configuration
*/
@Bean
public InternalResourceViewResolver htmlViewResolver() {
InternalResourceViewResolver resolver= new InternalResourceViewResolver();
resolver.setPrefix("/");
resolver.setSuffix(".html");
return resolver;
}
//**************************************************************************************************
// Getter/Setter Methods
//**************************************************************************************************
//**************************************************************************************************
// Static Methods
//**************************************************************************************************
//**************************************************************************************************
// Inner Classes
//**************************************************************************************************
}