//FreeMarkerView类中相关代码 protected FreeMarkerConfig autodetectConfiguration()throws BeansException { try { return BeanFactoryUtils.beanOfTypeIncludingAncestors( getApplicationContext(), FreeMarkerConfig.class, true, false); } catch (NoSuchBeanDefinitionException ex) { thrownew ApplicationContextException( "Must define a single FreeMarkerConfig bean in this web application context " + "(may be inherited): FreeMarkerConfigurer is the usual implementation. " + "This bean may be given any name.", ex); } }
@Bean public CompactDisc sgtPeppers(){ BlankDisc cd = new BlankDisc(); cd.setTitle("Sgt. Pepper's Lonely Hearts Club Band"); cd.setArtist("The Beatles"); List<String> tracks = new ArrayList<String>(); tracks.add("Sgt. Pepper's Lonely Hearts Club Band"); tracks.add("With a Little Help from My Friends"); tracks.add("Lucy in the Sky with Diamonds"); tracks.add("Getting Better"); tracks.add("Fixing a Hole"); // ...other tracks omitted for brevity... cd.setTracks(tracks); return cd; }
@Bean public TrackCounter trackCounter(){ returnnew TrackCounter(); } }