spring4 获取泛型信息

public interface TestService<Question> {
	
	public String test();
	
}


@Service
public class TestServiceImpl implements TestService<Question> {

	@Override
	public String test() {
		String abc = "abc";
		return abc;
	}

}

@Controller
@RequestMapping("/test")
public class TestController {
	
	@Autowired
	private TestService<Question> testService;
	
	@RequestMapping
	public String index(){
		testService.test();
	    ResolvableType resolvableType2 =  ResolvableType.forField(ReflectionUtils.findField(TestController.class, "testService"));  
	    System.out.println(resolvableType2.getGeneric(0).resolve());
	    return "index";
	}
	
}


你可能感兴趣的:(spring4 获取泛型信息)