:
public class BaseController
{
protected String field;
protected void method()
{
System.out.println("I'm protected method");
}
}
@RestController
@RequestMapping("/stack")
public class StackController extends BaseController
{
class Inner
{
public void methodInvocation()
{
method();
}
public void fieldInvocation()
{
field = "Test";
}
}
@RequestMapping(value= {"/invoca"}, method= {RequestMethod.GET})
public ResponseEntity<String> invocation()
{
Inner in = new Inner();
in.fieldInvocation();
in.methodInvocation();
return new ResponseEntity<String>("OK", HttpStatus.OK);
}
}
, . Spring (, ):
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = { "it.spring.controller" })
@PropertySource( value={"classpath:config.properties"}, encoding="UTF-8", ignoreResourceNotFound=false)
public class DbConfig
{
}
@Configuration
@EnableWebMvc
@Import(DbConfig.class)
@PropertySource(value = { "classpath:config.properties" }, encoding = "UTF-8", ignoreResourceNotFound = false)
public class WebMvcConfig extends WebMvcConfigurerAdapter
{
}
, @Import, web.xml :
<servlet>
<servlet-name>SpringDispSvlt</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>it.WebMvcConfig</param-value>
</init-param>
<init-param>
<param-name>dispatchOptionsRequest</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
/
, , ?
,