出于监管和安全原因,我不得不将 Spring boot 应用程序的逻辑拆分为两个工具:一个用于管理有限数量的表,另一个用于“真实”用户应用程序。因此,我在服务器版本 5.7 上有两个 MySQL 数据库实例。虽然用户工具只访问一个包含几十个表的数据库,但管理工具需要访问两个数据库中的实体。
这些工具都基于 JavaFX 和 Spring Boot。由于这种架构设置,我有三个 maven 包:一个用于管理工具和所有与管理相关的实体、服务等,一个用于用户工具和所有相关实体、服务等。仅与此用户工具相关,第三个与这两个工具共享的所有实体。
当我运行用户工具时,它会在共享数据库中生成表,并根据其 application.properties 文件中的配置使用休眠改进命名策略。因此,列在适当的地方有一个下划线。
首先,管理工具根本不会使用 spring.jpa.hibernate.ddl-auto 创建任何数据库表,但我必须使用 spring.jpa.generate-ddl。
现在,当我运行管理工具时,我希望它只在管理数据库中创建表,因为这个数据源被注释为@Primary。但它也会在用户数据库中创建混合大小写的列。因此,我在用户数据库中有名为“email_address”和“emailAddress”的列。
我想知道我的方法是否使用了任何属性?任何想法如何正确地做到这一点?
请找到以下一些来源..
application.properties :
# Employee database
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbcUrl=jdbc:mysql://127.0.0.1/agiletunesdb?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&characterSetResults=utf-8
spring.datasource.username=YYY
spring.datasource.password=XXXXXX
# Account database
security.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
security.datasource.jdbcUrl=jdbc:mysql://127.0.0.1/authenticationdb?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&characterSetResults=utf-8
security.datasource.username=YYY
security.datasource.password=XXXXXX
# create db schema, values are none, validate, update, create, and create-drop.
#spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=update
#spring.jpa.hibernate.ddl-auto=none
spring.jpa.generate-ddl=true
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
蝴蝶刀刀
相关分类