尝试使用jasypt加密值连接oracle数据库时出错

时间:2014-08-04 14:16:16

标签: xml oracle apache-camel jasypt

我正在尝试通过使用camel-jasypt生成加密密码和用户名来连接oracle数据库,方法是将生成的值保存在.properties文件中。但不幸的是,我遇到的用户名和密码错误都不正确。我正在提供我的程序的驼峰语境。                      

    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"/>
        <property name="location" value="classpath:DB.properties"/>
        <property name="propertiesParser" ref="jasypt"/>
    </bean>
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:xe"/>
        <property name="username" value="${db.username}"/>
        <property name="password" value="${db.password}"/>
         </bean>
       </beans>

我将所有用户名,密码,oracle jdbc驱动程序和url连接到.properties文件中的数据库。我在Apache camel软件分发中使用camel-jasypt jar加密了我的用户名和密码,我有点怀疑,我可以加密用户名和密码,或只加密一个用户名或密码,但我尝试加密。我的属性文件是

            db.driverClassName=oracle.jdbc.driver.OracleDriver
            db.url=jdbc:oracle:thin:@127.0.0.1:1521:xe
            db.username=ENC(/leiK3jiyKe1y87A8i743g==)
            db.password=ENC(3bwhRqBKu1Pye4Z+gBz9mm9q5Nxgah0n)

当我尝试使用.properties文件中的加密值连接oracle数据库时,我面临错误以下错误

[ERROR] Error occurred while running main from: org.apache.camel.spring.Main
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'properties' defined in file [C:\Users\761285\workspace\camel-jasyp\target\classes\META-INF\spring\camelContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel-1': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in file [C:\Users\rahul\workspace\camel-jasyp\target\classes\META-INF\spring\camelContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
(ClassPathXmlApplicationContext.java:93)

1 个答案:

答案 0 :(得分:0)

基于例外情况:

nested exception is 
  org.springframework.beans.factory.CannotLoadBeanClassException: 
    Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean 
    with name 'dataSource' 

您的应用程序找不到此类,您必须将apache-common.jar添加到pom或classpath或存储库的任何位置。