[英]Spring MVC web app cannot find org.apache.commons.dbcp.BasicDataSource class
Im trying to setup a Spring MVC web app using Hibernate ORM. 我试图使用Hibernate ORM设置Spring MVC Web应用程序。 Im using JBOSS AS.
我正在使用JBOSS AS。
There is a problem when Im trying to define a datasource bean: 我试图定义数据源bean时出现问题:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
When I run the app and access it via browser, it throws an exception - 当我运行该应用并通过浏览器访问该应用时,它会引发异常-
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/servletCtx.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource from [Module "deployment.untitled1.war:main" from Service Module Loader]
I've read somewhere that this datasource approach is old and deprecated. 我在某个地方读到这种数据源方法过时且过时。 Is it true?
是真的吗 What else would you suggest?
您还有什么建议?
Thanks for hints and help. 感谢您的提示和帮助。
java.lang.ClassNotFoundException
means the required JAR file that contains org.apache.commons.dbcp.BasicDataSource
is not available in classpath, just add it to fix the issue. java.lang.ClassNotFoundException
意味着包含org.apache.commons.dbcp.BasicDataSource
的必需JAR文件在classpath中不可用,只需添加它即可解决此问题。
Instead of configuring it as a data-source use JNDI connection. 与其将其配置为数据源,不如使用JNDI连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.