如何将石英指向Spring Hikaricp DataSource?

发布于 2025-02-04 18:53:35 字数 1393 浏览 3 评论 0原文

属性设置一个简单的数据源

spring.datasource.username=${database.username}
spring.datasource.password=${database.password}
spring.datasource.url=jdbc:mysql://${database.host}/databasename

我的应用程序是通过hikari autoconfig拾取的

。但是,当使用localdatasourcejobstore

<bean id="QuartzClusteredScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <!-- <property name="dataSource" ref="????"/> -->
    <property name="jobFactory">
        <bean class="com.example.scheduler.AutowiringSpringBeanJobFactory"/>
    </property>
    <property name="quartzProperties">
        <props>
            <prop key="org.quartz.jobStore.class">org.springframework.scheduling.quartz.LocalDataSourceJobStore</prop>
    <property name="jobDetails">
        <list>...

Quartz指向Hikaricp池的正确方法是什么?

如果我归因于数据源,就像我的春季石英autoconfigure的手册所建议的那样,我得到了 java.sql.sqlexception:没有名为'null''的数据源 如果我放任何其他名称并使用spring.datasource.name = abc,那么我发现它找不到abcjdbc/abc同样。

我正在尝试了解 https://github.com/spring -Projects/spring-boot/eskity/28758 这似乎是影响我的原因,但是一切都会如此轻松地提到,我不确定如何遵循。

my application is setting a simple data source via properties

spring.datasource.username=${database.username}
spring.datasource.password=${database.password}
spring.datasource.url=jdbc:mysql://${database.host}/databasename

which gets picked up by hikari autoconfig.

But then fail to be seen be quartz autoconfig when using LocalDataSourceJobStore

<bean id="QuartzClusteredScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <!-- <property name="dataSource" ref="????"/> -->
    <property name="jobFactory">
        <bean class="com.example.scheduler.AutowiringSpringBeanJobFactory"/>
    </property>
    <property name="quartzProperties">
        <props>
            <prop key="org.quartz.jobStore.class">org.springframework.scheduling.quartz.LocalDataSourceJobStore</prop>
    <property name="jobDetails">
        <list>...

What is the correct way to point quartz to the hikariCP pool?

If I ommit the dataSource attributed, like I the manual for spring's quartz autoconfigure suggests, I get
java.sql.SQLException: There is no DataSource named 'null'
If i put any other name and use spring.datasource.name=abc then i get that it can't find abc or jdbc/abc just the same.

I'm trying to understand the discussion on https://github.com/spring-projects/spring-boot/issues/28758 which seems to be what is affecting me, but everything is mentioned so lightly i am not sure how to follow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀念你的温柔 2025-02-11 18:53:35

您可以在application.properties中明确设置数据源名称。

spring.datasource.mysql.username=${database.username}
spring.datasource.mysql.password=${database.password}
spring.datasource.mysql.url=jdbc:mysql://${database.host}/databasename

然后,在您的bean定义中,您可以尝试参考此数据源。

我刚刚在: http:http: //www.masterspringboot.com/programming/various/getting-with-with-quartz-and-spring-boot/

也许您可以从一开始就可以尝试代码。

You can explicitly set the datasource name in your application.properties.

spring.datasource.mysql.username=${database.username}
spring.datasource.mysql.password=${database.password}
spring.datasource.mysql.url=jdbc:mysql://${database.host}/databasename

Then in your bean definition, you can try to ref this datasource.

I just found an example at: http://www.masterspringboot.com/programming/various/getting-started-with-quartz-and-spring-boot/

Maybe you can try the code from very beginning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文