Java 用户必须在hibernate中提供JDBC连接

Java 用户必须在hibernate中提供JDBC连接,java,spring,hibernate,maven,javafx,Java,Spring,Hibernate,Maven,Javafx,我的问题是出错 用户必须提供JDBC连接 我正在使用hibernate,spring和javafx 休眠Spring配置文件 dispatcher-servlet.xml Maven pom文件 pom.xml 4.0.0 斯科帕达 什里盖姆斯 0.0.1-快照 src src **/*.爪哇 org.apache.maven.plugins maven编译器插件 3.6.0 1.8 1.8 4.3.5.1发布 8.40.12 5.2.1.最终版本 3.3.0.ga 5.2.5.最终版本 ja

我的问题是出错

用户必须提供JDBC连接

我正在使用hibernate,spring和javafx

休眠Spring配置文件

dispatcher-servlet.xml

Maven pom文件

pom.xml


4.0.0
斯科帕达
什里盖姆斯
0.0.1-快照
src
src
**/*.爪哇
org.apache.maven.plugins
maven编译器插件
3.6.0
1.8
1.8
4.3.5.1发布
8.40.12
5.2.1.最终版本
3.3.0.ga
5.2.5.最终版本
javax.transaction
jta
1.1
org.controlsfx
controlsfx
${controlsfx.version}
org.xerial
sqlite jdbc
3.15.1
org.apache.poi
poi
3.16-β1
org.apache.poi
poi ooxml模式
3.16-β1
org.apache.poi
poi ooxml
3.16-β1
org.apache.poi
卓越的
3.16-β1
org.springframework
弹簧芯
${spring.version}
org.springframework
春季aop
${spring.version}
org.springframework
春豆
${spring.version}
org.springframework
spring上下文
${spring.version}
org.springframework
SpringJDBC
${spring.version}
org.springframework
弹簧网
${spring.version}
org.springframework
SpringWebMVC
${spring.version}
org.springframework
spring上下文支持
${spring.version}
org.springframework
SpringJMS
${spring.version}
org.springframework
春季方面
${spring.version}
org.springframework
spring消息
${spring.version}
org.springframework
春季甲虫
${spring.version}
org.hibernate
休眠搜索orm
${hibernate search orm.version}
org.hibernate
hibernate commons注释
${hibernate commons annotations.version}
org.hibernate
hibernate-c3p0
${hibernate.version}
org.hibernate
休眠ehcache
${hibernate.version}
org.hibernate
冬眠核心
${hibernate.version}
org.hibernate
休眠实体管理器
${hibernate.version}
我在网上出错了

上下文=新 ClassPathXmlApplicationContext(“/application/controller/dispatcherservlet.xml”)

public void recursiveWire(对象根)引发异常{

context=newclasspathXMLApplicationContext(“/application/controller/dispatcherservlet.xml”); getAutowireCapableBeanFactory().autowireBean(根); getAutowireCapableBeanFactory().initializeBean(根,null); for(字段:root.getClass().getDeclaredFields()){ if(field.isAnnotationPresent(FXML.class)和&!Node.class.isAssignableFrom(field.getType()){
//您的hibernate配置文件使用了错误的参数名称。正确的参数名称如下:

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
hibernate.dialect
hibernate.show_sql

请更正参数名称,然后重试。

您的hibernate配置文件使用了错误的参数名称。正确的参数名称如下所示:

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
hibernate.dialect
hibernate.show_sql

请更正您的参数名称,然后重试。

您可以更好地使用此dispacher-servlet.xml格式进行尝试。这必须正常工作

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="base"/>
    <mvc:annotation-driven/>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />
    <bean id="propertyConfiguration" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="/WEB-INF/jdbc.properties"/>
    </bean>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseUrl}"
          p:username="${jdbc.userName}"
          p:password="${jdbc.password}"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResources">
            <list>
                <value>
                    base/model/Product.hbm.xml
                </value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=true
            </value>
        </property>

    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />

    </bean>


</beans>

base/model/Product.hbm.xml
hibernate.dialogue=org.hibernate.dialogue.mysqldialogue
hibernate.show_sql=true

您可以更好地尝试使用此dispacher-servlet.xml格式。该格式必须有效

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="base"/>
    <mvc:annotation-driven/>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />
    <bean id="propertyConfiguration" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="/WEB-INF/jdbc.properties"/>
    </bean>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseUrl}"
          p:username="${jdbc.userName}"
          p:password="${jdbc.password}"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResources">
            <list>
                <value>
                    base/model/Product.hbm.xml
                </value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=true
            </value>
        </property>

    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />

    </bean>


</beans>

base/model/Product.hbm.xml
hibernate.dialogue=org.hibernate.dialogue.mysqldialogue
hibernate.show_sql=true

context=new ClassPathXmlApplicationContext(“/application/controller/dispatcher servlet.xml”);您正在尝试加载dispatcher-servlet.xml?而您在config.xml?中提到了bean。请共享错误日志以提及config.xml中的bean?您已经在config.xml中提到了bean。加载config.xml而不是dispatcher-servlet.xml。dispatcher-servlet.xml中存在什么?这是我的错误。查看我的上一次更新。contex
hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
hibernate.dialect
hibernate.show_sql
<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="base"/>
    <mvc:annotation-driven/>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />
    <bean id="propertyConfiguration" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="/WEB-INF/jdbc.properties"/>
    </bean>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseUrl}"
          p:username="${jdbc.userName}"
          p:password="${jdbc.password}"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResources">
            <list>
                <value>
                    base/model/Product.hbm.xml
                </value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=true
            </value>
        </property>

    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />

    </bean>


</beans>