在无构造函数或setter的基于java的配置中设置Bean属性
我正在尝试设置Velocity模板引擎以与SpringMVC一起使用。 我的项目目前只使用基于java的spring配置 我无法设置在无构造函数或setter的基于java的配置中设置Bean属性,java,spring,spring-mvc,velocity,Java,Spring,Spring Mvc,Velocity,我正在尝试设置Velocity模板引擎以与SpringMVC一起使用。 我的项目目前只使用基于java的spring配置 我无法设置速度配置程序 根据Spring文档,我应该如下创建bean: <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath" value=
速度配置程序
根据Spring文档,我应该如下创建bean:
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/velocity/"/>
</bean>
有没有办法避免在这里进行基于.xml的配置?根据javadoc,它有一个用于的setter。setter继承自
因此,应该可以设置它:
@Bean
public VelocityConfigurer velocityConfig() {
VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
velocityConfigurer.setResourceLoaderPath("/WEB-INF/velocity/");
return velocityConfigurer;
}
谢谢我一定是瞎了(
@Bean
public VelocityConfigurer velocityConfig() {
VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
velocityConfigurer.setResourceLoaderPath("/WEB-INF/velocity/");
return velocityConfigurer;
}