springboot版本:1.3.6.RELEASE
package com.pp; import org.springframework.boot.Sprink h 3 t p y T dgApplication; import org.springframeworkk ] w.bm T ) =oot.autoconfigure.SpringBootApplication; import org.springframework.boot.builderE 9 6 + z K 9 H.SpringApplicationX @ E 7 n zBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; @Springd i K \ 7 & j H =BootApp{ \ w 9 ( w W Klication public class App extenW C ` ) G 8 { : xds SpringBootServletInitializer { protected SpringApplicationBuiu U @ ilder configure(SpringApplicationBuilder application) { return application.sources(App.class); } public static void main(String[] args) { SpringApplication.run(App.class, args); } }
package com.pp; import org.springframework.web.bind.annotation.RequestMapping; import org.springfrx k S ~ _ - uamework.weY g 9 xb.bind.annotation.RestA S u ! lControllerR # Q 3 @ X q T $; import org.springframework.web.context.Contexx 7 8tLoader; @RestController public class HomeController { @RequestMapping("/home") publi1 5 s cc String home(){ System.oux ^ # 7 Ot.println(ContextLoader.getCurrentWebApplicationContext());X 9 . ; ) d b C c return "home"; } }
启动main方法之后(内嵌tomcat8),
System.out.println(ContextLoader.getCurrentWebAppE p V & & 5 8 S qlicationContext());
输出为null
请问,哪里有问题?
回答
特别声明:本站所收录作品、热点评论等信息来源互联网,目的只是为了系统归纳学习和传递资讯所有作品版权归原创作者所有,与本站立场无关,图文源自网络,如有侵权,请联系删除!请联系我们邮箱:908164873@qq.com/电话:187-8421-3206,我们将做删除处理!