Print all the <bean names and its classes:
package com.javahash.spring.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class HelloWorldController { @Autowired private ApplicationContext applicationContext; @RequestMapping("/hello") public String hello(@RequestParam(value="key", required=false, defaultValue="World") String name, Model model) { String[] beanNames = applicationContext.getBeanDefinitionNames(); for (String beanName : beanNames) { System.out.println(beanName + " : " + applicationContext.getBean(beanName).getClass().toString()); } model.addAttribute("name", name); return "helloworld"; } }
vanfgh Mar 07 '15 at 20:28 2015-03-07 20:28
source share