【问题标题】:JDBC driver not available for 'org.postgresql.Driver' on Spring RooJDBC 驱动程序不适用于 Spring Roo 上的“org.postgresql.Driver”
【发布时间】:2016-12-16 17:39:23
【问题描述】:

我正在尝试使用 database reverse engineer... 查看完整的 Roo v1.3 脚本和 UBUNTU env,地址为 this simple "hello" script

错误:

Located add-ons that may offer this JDBC driver
2 found, sorted by rank; T = trusted developer; R = Roo 1.3 compatible
ID T R DESCRIPTION -------------------------------------------------------------
01 Y Y 9.1.0.901-1_0001 Postgres #jdbcdriver...
02 Y Y 9.1.0.901_0001 Postgres #jdbcdriver...
--------------------------------------------------------------------------------
[HINT] use 'addon info id --searchResultId ..' to see details about a search result
[HINT] use 'addon install id --searchResultId ..' to install a specific search result, or
[HINT] use 'addon install bundle --bundleSymbolicName TAB' to install a specific add-on version
JDBC driver not available for 'org.postgresql.Driver'

注意事项

这是spring.io/spring-roo 快速指南 10 行示例的变体。很简单……

这是在项目和数据库 Roo 初始化之后(并且工作正常),

project --topLevelPackage   com.testRoo1Hello2pg
jpa setup --provider HIBERNATE --database POSTGRES --databaseName hello2db --userName postgresql --password postgres

database.properties 似乎:

database.driverClassName=org.postgresql.Driver
database.url=jdbc\:postgresql\://localhost\:5432/hello2db
database.username=postgresql
database.password=postgres

spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.hibernate.ddl-auto=create-drop

失败的命令是:

database reverse engineer --schema public --includeTables "test1"

更多详情请见roo1/hello3pg.md

【问题讨论】:

标签: spring-roo


【解决方案1】:

Spring Roo shell 向您显示的消息不是错误。让我们检查一下:

Located add-ons that may offer this JDBC driver
2 found, sorted by rank; T = trusted developer; R = Roo 1.3 compatible
ID T R DESCRIPTION -------------------------------------------------------------
01 Y Y 9.1.0.901-1_0001 Postgres #jdbcdriver...
02 Y Y 9.1.0.901_0001 Postgres #jdbcdriver...
--------------------------------------------------------------------------------
[HINT] use 'addon info id --searchResultId ..' to see details about a search result
[HINT] use 'addon install id --searchResultId ..' to install a specific search result, or
[HINT] use 'addon install bundle --bundleSymbolicName TAB' to install a specific add-on version
JDBC driver not available for 'org.postgresql.Driver'

执行database reverse engineer --schema public --includeTables "test1" 命令后会出现此消息。

Spring Roo 正在尝试连接 Postgres 数据库,但是......哦哦......在 OSGi 上下文中部署的 Postgres 数据库不存在 JDBC 驱动程序(请记住,Spring Roo 在 OSGi 环境下工作),所以不可能与数据库连接。

Spring Roo shell 为您提供了一些选项来解决上述问题。因此,如果您阅读了该消息,您可以检查您是否能够使用以下命令将 Postgres JDBC 驱动程序安装到 OSGi 上下文中。

addon install bundle --searchResultId 01

(01 id为id栏下的数字)

执行安装 OSGi 包的命令后,再次尝试执行逆向工程命令。

应该可以!

希望对你有帮助,

注意:如果您有兴趣了解更多关于 OSGi 和 Apache Felix 实现的信息,您可以阅读 http://felix.apache.org/https://www.osgi.org/developer/specifications/

【讨论】:

  • 感谢@jcgarcia,现在它正在工作! HINT 的使用不是很友好,容易出错...我可以在github.com/spring-roo 报告问题,但没有启用/issues。好吧,现在正在工作,但没有按预期 100% 工作:我没有看到约束(如“DEFAULT 99”、“NOT NULL”或“CHECK”),也没有看到 Table.java* 中的字段声明生成的代码。
  • 操作,对于读者(也适用于 jcgarcia):安装的命令是 addon install id --searchResultId 01 而不是 install bundle ...我对 install bundle 有问题,没有执行任何 adicional 安装。
【解决方案2】:

我都试过了

addon install bundle --searchResultId 01

addon install bundle --searchResultId 02

并且仍然收到未找到驱动程序消息JDBC driver not available for 'org.postgresql.Driver'

对我有用的是安装以前版本的捆绑包。

osgi install --url  http://spring-roo-repository.springsource.org/release/org/springframework/roo/wrapping/org.springframework.roo.wrapping.postgresql-jdbc3/9.0.801.0001/org.springframework.roo.wrapping.postgresql-jdbc3-9.0.801.0001.jar

我正在使用在 docker 容器上运行的 PostgreSQL 9.4。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 2011-12-16
    相关资源
    最近更新 更多