spring数据库中的匿名用户

时间:2017-11-28 13:19:24

标签: database spring maven

我想使用celerio框架根据我的数据库架构生成代码。 celerio是一个基于maven-sql-plugin和spring的maven插件。

我希望在没有明确的用户/通过身份验证的情况下连接到我的数据库。我们的数据库连接不需要用户/通行证,它是匿名登录。

celerio框架附带了一个用于spring配置的预定义applicationContext.xml。

    <?xml version="1.0" encoding="UTF-8"?>
<!-- ! Source code generated by Celerio, a Jaxio product. ! Documentation: 
    http://www.jaxio.com/documentation/celerio/ ! Follow us on twitter: @jaxiosoft 
    ! Need commercial support ? Contact us: info@jaxio.com ! Template pack-backend-jpa:src/main/resources/spring/applicationContext.p.vm.xml 
    ! Template is part of Open Source Project: https://github.com/jaxio/pack-backend-jpa -->
<beans default-lazy-init="true"
    xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd">
    <description><![CDATA[
        Main entry point for spring configuration
    ]]></description>

    <!-- context -->
    <context:component-scan base-package="com.jaxio.jpa.querybyexample" />
    <context:component-scan base-package="ch.siemens.ts.ilat.book_application">
        <!-- exclude web beans as they live in the web application context -->
        <!-- Note: this regexp does not work if you try to escape the '.' -->
        <context:exclude-filter type="regex"
            expression="ch.siemens.ts.ilat.book_application.web.*" />
    </context:component-scan>
    <context:property-placeholder
        location="classpath*:database.properties,classpath*:hibernate.properties,classpath*:app-version.properties" />

    <!-- security -->
    <security:authentication-manager>
        <security:authentication-provider user-service-ref="userDetailsService" />              
    </security:authentication-manager>
    <security:global-method-security jsr250-annotations="enabled" pre-post-annotations="enabled" />

    <!-- task -->
    <task:annotation-driven executor="myExecutor" scheduler="myScheduler" />
    <task:executor id="myExecutor" pool-size="5" />
    <task:scheduler id="myScheduler" pool-size="10" />

    <!-- transaction -->
    <tx:annotation-driven />
    <!-- datasource -->
    <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" 
    destroy-method="close"
    lazy-init="false"
    p:driverClassName="${jdbc.driver}"
    p:url="${jdbc.url}"
    p:username="${jdbc.user}"
    p:password="${jdbc.password}"
    p:initialSize="1"
    p:maxActive="50"
    p:maxIdle="10"
    p:maxWait="1000"
    p:defaultAutoCommit="false"
    p:removeAbandoned="true"
    p:removeAbandonedTimeout="60">
    <description><![CDATA[
    Simple datasource. This is a direct access to the datasource that can 
    be used for specific queries that need to bypass JPA functionalities. 
    However, if you need to use JDBC, please look at hibernate SQL-QUERIES, 
    they would most probably be a more elegant way to solve your problem.
    ]]></description>
    </bean>

</beans>

如何更改此应用程序上下文以允许匿名登录数据库?

当我运行celerio时,我得到以下错误:

[DEBUG] Configuring mojo com.jaxio.celerio:dbmetadata-maven-plugin:4.0.23:extract-metadata from plugin realm ClassRealm[plugin>com.jaxio.celerio:dbmetadata-maven-plugin:4.0.23, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'com.jaxio.celerio:dbmetadata-maven-plugin:4.0.23:extract-metadata' with basic configurator -->
[DEBUG]   (f) jdbcCatalog = 
[DEBUG]   (f) jdbcDriver = com.ingres.jdbc.IngresDriver
[DEBUG]   (f) jdbcOracleRetrieveRemarks = false
[DEBUG]   (f) jdbcOracleRetrieveSynonyms = true
[DEBUG]   (f) jdbcPassword = 
[DEBUG]   (f) jdbcReverseViews = false
[DEBUG]   (f) jdbcTableNamePatterns = []
[DEBUG]   (f) jdbcUrl = jdbc:ingres://localhost:ii7/bjax::entw_frm_db
[DEBUG]   (f) jdbcUser = 
[DEBUG]   (f) project = MavenProject:    ch.siemens.ts.ilat.book_application:book_application:1.0.0-SNAPSHOT @ D:\ILAT\develop\e_oxy_mvn_iaf\book_application\pom.xml
[DEBUG]   (f) reverseIndexes = true
[DEBUG]   (f) reverseOnlyUniqueIndexes = true
[DEBUG]   (f) skip = false
[DEBUG]   (f) targetFilename = D:\ILAT\develop\e_oxy_mvn_iaf\book_application/src/main/config/celerio-maven-plugin/metadata.xml
[DEBUG] -- end configuration --
[ERROR] jdbcUser missing
[ERROR] Please update your jdbc configuration so we can reverse your database
[ERROR] aborting

0 个答案:

没有答案