日期:2014-05-20  浏览次数:20808 次

关于paoding-rose的问题
熟悉这个标题的同学请看下,最近研究人人网paoding-rose框架,准备做一个简单的B/S架构的小东西,原来是为了快速开发,但是弄了两天了,仍然存在问题。
 
Java code
package com.text.controllers;

import org.springframework.beans.factory.annotation.Autowired;

import com.text.dao.UserDao;

public class UserController {
    
    @Autowired
    private UserDao userDao;
    public String login()
    {
        return "@测试成功"+userDao.getUser(1);
    }
}


这是controller
Java code
package com.text.dao;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;

@DAO(catalog="dataSource")
public interface UserDao {

    @SQL("select name from user where id=:1")
    public String getUser(int id);
}

这是userdao
XML code
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
      <filter>
        <filter-name>roseFilter</filter-name>
        <filter-class>net.paoding.rose.RoseFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>roseFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
</web-app>



XML code
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
    default-lazy-init="true">
        <!--
            这里使用Spring自带的DriverManagerDataSource,实际开发产品应该使用具有连接持管理的DataSource等
        -->
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url"
                value="jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;characterEncoding=utf8" />
            <property name="username" value="root" />
            <property name="password" value="root" />
        </bean>
    </beans>


这是applicationcontext-datasources。xml 没有其他配置文件了,希望懂的帮下忙。每次运行,直接报错

说是严重: Exception starting filter roseFilter
org.springframework.web.util.NestedServletException: [Rose-1.0.1-20100604@Spring-2.5.6.SEC01]:Error creating bean with name 'ModuleBuilder.com.text.controllers.UserController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.text.dao.UserDao com.text.controllers.UserController.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.text.dao.UserDao': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: not found dataSource for catalog: 'dataSource'; you should set a dataSource bean (with id='jade.dataSource[.daopackage[.daosimpleclassname]]' or 'dataSource' )in applicationContext for this catalog.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ModuleBuilder.com.text.controllers.UserController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.text.dao.UserDao com.text.controllers.UserController.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.text.dao.UserDao': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: not found dataSource for catalog: 'dataSource'; you should set a dataSource bean (with id='jade.dataSource[.daopackage[.daosimpleclassname]]' or 'dataSource' )in applicationContext for this catalog.
at net.paoding.rose.RoseFilter.initFilterBean(RoseFilter.java:296)
at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:179)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4071)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4725)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)




就在发帖的瞬间,居然把问题解决了,不过我还是要发帖,白白浪费了四十分,当做周五散分了


------解决方案--------------------
朋友,,你怎样解决的呢??我没搞明哪里出错的,,说说,谢谢 了