- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 Spring Boot 中配置 2 个 JNDI 数据源。我试过这个配置:
application.properties
spring.production-datasource.jndi-name=java:/global/production_gateway
spring.production-datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.warehouse-datasource.jndi-name=java:/global/production_warehouse
spring.warehouse-datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.production.entity",
entityManagerFactoryRef = "productionEntityManager",
transactionManagerRef = "productionTransactionManager"
)
@EnableTransactionManagement
public class ContextProductionDatasource {
@Autowired
private Environment env;
@Primary
@Bean(name = "productionDataSourceProperties")
@ConfigurationProperties(prefix="spring.production.datasource")
public DataSourceProperties productionDataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean(name = "productionDataSource")
@ConfigurationProperties(prefix="spring.production.datasource")
public DataSource productionDataSource() {
return DataSourceBuilder.create().build();
}
@Primary
@Bean(name = "productionEntityManager")
public EntityManager productionEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Primary
@Bean(name = "productionTransactionManager")
public PlatformTransactionManager productionTransactionManager(final EntityManagerFactory emf) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
@Primary
@Bean(name = "productionExceptionTranslation")
public PersistenceExceptionTranslationPostProcessor productionExceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
}
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.warehouse.entity",
entityManagerFactoryRef = "warehouseEntityManager",
transactionManagerRef = "warehouseTransactionManager"
)
@EnableTransactionManagement
public class ContextWarehouseDatasource {
@Autowired
private Environment env;
@Bean(name = "warehouseDataSourceProperties")
@ConfigurationProperties(prefix="spring.warehouse.datasource")
public DataSourceProperties warehouseDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "warehouseDataSource")
@ConfigurationProperties(prefix="spring.warehouse.datasource")
public DataSource warehouseDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "warehouseEntityManager")
public EntityManager warehouseEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Bean(name = "warehouseTransactionManager")
public PlatformTransactionManager warehouseTransactionManager(final EntityManagerFactory emf) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
@Bean(name = "warehouseExceptionTranslation")
public PersistenceExceptionTranslationPostProcessor warehouseExceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
}
Caused by: java.lang.IllegalStateException: Unable to set value for property driver-class-name
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.setValue(JavaBeanBinder.java:349)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:96)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:79)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:56)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:452)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:570)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:556)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:513)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:450)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:391)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320)
... 132 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at deployment.datalis_rest_api.war//org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.setValue(JavaBeanBinder.java:346)
... 142 more
Caused by: java.lang.RuntimeException: Failed to load driver class org.mariadb.jdbc.Driver in either of HikariConfig class loader or Thread context classloader
at deployment.datalis_rest_api.war//com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:485)
spring.production.datasource.jndi-name=java:/global/production_gateway
spring.production.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.production.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.production.jpa.show-sql = true
spring.production.jpa.hibernate.ddl-auto = update
spring.warehouse.datasource.jndi-name=java:/global/production_warehouse
spring.warehouse.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.warehouse.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.warehouse.jpa.show-sql = true
spring.warehouse.jpa.hibernate.ddl-auto = update
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.production.entity",
entityManagerFactoryRef = "productionEntityManager",
transactionManagerRef = "productionTransactionManager"
)
@EnableTransactionManagement
public class ContextProductionDatasource {
@Primary
@Bean(name = "productionDataSourceProperties")
@ConfigurationProperties(prefix="spring.production")
public DataSourceProperties productionDataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean(name = "productionDataSource")
@ConfigurationProperties(prefix="spring.production")
public DataSource productionDataSource() {
return DataSourceBuilder.create().build();
}
@Primary
@Bean(name = "productionEntityManager")
public EntityManager productionEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Primary
@Bean(name = "productionTransactionManager")
public PlatformTransactionManager productionTransactionManager(final EntityManagerFactory emf) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
@Primary
@Bean(name = "productionExceptionTranslation")
public PersistenceExceptionTranslationPostProcessor productionExceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
}
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.warehouse.entity",
entityManagerFactoryRef = "warehouseEntityManager",
transactionManagerRef = "warehouseTransactionManager"
)
@EnableTransactionManagement
public class ContextWarehouseDatasource {
@Bean(name = "warehouseDataSourceProperties")
@ConfigurationProperties(prefix="spring.warehouse")
public DataSourceProperties warehouseDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "warehouseDataSource")
@ConfigurationProperties(prefix="spring.warehouse")
public DataSource warehouseDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "warehouseEntityManager")
public EntityManager warehouseEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Bean(name = "warehouseTransactionManager")
public PlatformTransactionManager warehouseTransactionManager(final EntityManagerFactory emf) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
@Bean(name = "warehouseExceptionTranslation")
public PersistenceExceptionTranslationPostProcessor warehouseExceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
}
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
at deployment.datalis_rest_api.war//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at deployment.datalis_rest_api.war//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:640)
... 41 more
Caused by: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
最佳答案
更正两个 entityManager bean 的名称:productionEntityManager 和仓库实体管理器entityManagerFactoryRef
在 @EnableJpaRepositories
是 beanName 引用,
所以用
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.production.entity",
entityManagerFactoryRef = "productionEntityManager",
transactionManagerRef = "productionTransactionManager"
)
@EnableTransactionManagement
public class ContextProductionDatasource {
...
@Primary
@Bean
public EntityManager productionEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Configuration
@EnableJpaRepositories(
basePackages = "org.datalis.plugin.warehouse.entity",
entityManagerFactoryRef = "warehouseEntityManager",
transactionManagerRef = "warehouseTransactionManager"
)
@EnableTransactionManagement
public class ContextWarehouseDatasource {
...
@Bean
public EntityManager warehouseEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
@ConfigurationProperties
中的属性名称到属性值 '
- ' 与 '
. '
@ConfigurationProperties(prefix="spring.production-datasource")
和
@ConfigurationProperties(prefix="spring.warehouse-datasource")
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.5.2</version>
<scope>runtime</scope>
</dependency>
关于java - 无法加载驱动程序类 org.mariadb.jdbc.Driver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58999473/
我正在尝试获取此亚马逊页面中列出的每台笔记本电脑的图像 URL ( https://www.amazon.com/s?rh=n%3A565108%2Cp_72%3A4-&pf_rd_i=565108&
我正在设置 Atlassian Confluence,在选择数据库时,我在选择“使用外部 Mysql 数据库”时卡住了我看过一些教程,但对我来说,它并没有按照应有的方式工作。我使用 ubuntu 12
我是 Neo4J 的新手,正在尝试通过 java 连接到 Neo4J 服务器。 我的一个独立项目的pom入口如下: org.neo4j neo4j-o
所有这些有什么区别和用途? spark.local.ip spark.driver.host spark.driver.bind地址 spark.driver.hostname 如何将机器修复为 Sp
我在旧的 Inspiron 6400 计算机(GeForce 7300 笔记本电脑版)上安装了 Lubuntu 19.04,通过网络草稿编辑器教我儿子 Scratch。每次我通过 Firefox 打开
我使用 qt 开发了一个 c++ 库。在本文中,我使用 QSqlDatabase 从 SQLite 数据库中查询信息。注意:我的库在 qt 桌面应用程序中运行良好(我在 Linux 上开发)。 现在我
存在类似的问题,但没有帮助。 在 Apache 2.4 上安装 php5-fpm 通过 SSL 连接到远程 MySql 数据库。 可以通过命令行连接MySQL mysql -u myname -p'p
使用以下配置 (doctrine.yaml) 在 Symfony 4 中使用 Doctrine DBAL: dbal: # configure these for your database
使用以下配置 (doctrine.yaml) 在 Symfony 4 中使用 Doctrine DBAL: dbal: # configure these for your database
我有一个用 Java 编写的 Selenium Web 驱动程序测试,目标是 Liferay 站点。 // Login driver.get(baseUrl + "/"); driver.findEl
在driver.findElements()中,我们获得了另一个用于查找size()的函数,该函数在driver.findElement()中不可用。 这是唯一的区别吗? 最佳答案 driver.fi
这个问题已经有答案了: java.lang.IllegalStateException: The driver executable does not exist: while trying to e
简短描述:我有一个通过 SignTool 验证的签名驱动程序,但 Windows 拒绝加载它并出现错误:CodeIntegrity 3004 - 在系统上找不到文件哈希。我该如何解决这个问题? 详细说
我正在设置一些 Geb 测试,但出现“geb.driver.DriverCreationException:无法从回调创建驱动程序”错误。 Geb 将尝试启动测试浏览器窗口,但一旦启动,我的所有测试都
我想通过应用对象存储库概念在 Chrome 驱动程序中打开 url。下面给出的是我的 selenium 程序,其中包含两个文件,一个是 testng 文件,另一个是 config.property 文
我在 Ubuntu Linux、Spring Tools 2.7.1、Spring Roo 1.1.5 上运行 Eclipse Indigo。我正在阅读 Getting Started with Ro
打开 Url 的首选方法是什么(它们之间是否存在任何差异): driver.Url = "http://example.com"; 或 driver.Navigate().GoToUrl("http:
我使用 python 脚本传递给 cassandra 批处理查询,如下所示: query = 'BEGIN BATCH ' + 'insert into ... ; insert into ... ;
我在 Protractor 中执行脚本时出现以下错误。 System info: host: '8888', ip: '88888', os.name: 'Mac OS X', os.arch: 'x
我收到错误 KeyError:'driver'。 我想使用scrapy-selenium 创建一个网络爬虫。我的代码如下所示: class TestSpider(Spider): name="test
我是一名优秀的程序员,十分优秀!