NutzCN Logo
问答 spring使用nutDao,可以使用sql文件吗?如何配置?
发布于 1932天前 作者 qq_a1b6f073 1648 次浏览 复制 上一个帖子 下一个帖子
标签:
    如题;

    ```
    <!--nutz spring配置 -->
       <bean id="nutDao" class="org.nutz.dao.impl.NutDao">
         <property name="dataSource" ref="dataSource" />
         <property name="runner" ref="springDaoRunner" />
         <property name="sqlManager" ref="sql" />
       </bean>
       <bean id="sql" class="org.nutz.dao.impl.FileSqlManager">
         <property name="paths">
          <value>sqls/mysql</value>
         </property>
       </bean>
    ```
    我这样做报错:
    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nutDao' defined in class path resource [spring-config.xml]: Cannot resolve reference to bean 'sql' while setting bean property 'sqlManager';
    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sql' defined in class path resource [spring-config.xml]: Instantiation of bean failed; 
    nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.nutz.dao.impl.FileSqlManager]:
    No default constructor found; nested exception is java.lang.NoSuchMethodException: org.nutz.dao.impl.FileSqlManager.<init>()
2 回复

看FileSqlManager的构造方法,然后你就懂了

完美解决

<bean id="sqlManager" class="org.nutz.dao.impl.FileSqlManager">
		<constructor-arg>
			<array value-type="java.lang.String">
				<value>/conf/ioc/sqls/</value>
			</array>
		</constructor-arg>
	</bean>
添加回复
请先登陆
回到顶部