我正在尝试使用 micronaut (1.2.0) 的多个数据库连接,没有注入方法对我有用,这是我的配置:
应用.yml
datasources:
default:
url: ${JDBC_URL:`jdbc:mysql://localhost/cossine?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC`}
username: ${JDBC_USER:******}
password: ${JDBC_PASSWORD:*****}
driverClassName: ${JDBC_DRIVER:com.mysql.cj.jdbc.Driver}
keycloak:
url: ${JDBC_KYC_URL:`jdbc:mysql://localhost/keycloak?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC`}
username: ${JDBC_KYC_USER:******}
password: ${JDBC_KYC_PASSWORD:*******}
driverClassName: ${JDBC_DRIVER:com.mysql.cj.jdbc.Driver}
jpa:
default:
packages-to-scan:
- 'com.acmain.domain'
properties:
hibernate:
hbm2ddl:
auto: none
show_sql: false
keycloak:
packages-to-scan:
- 'com.acmain.kdomain'
properties:
hibernate:
hbm2ddl:
auto: none
show_sql: true
当我使用默认配置时,它可以正常工作,但是当使用第二个配置时,如下所示:
private final EntityManager entityManager;
public UserEntityImpl(@CurrentSession(value = "keycloak") EntityManager em) {
this.entityManager = em;
}
@Override
@Transactional
public UsersResponse findAll(@NotNull SortingAndOrderArguments args) {
List<UserEntity> users;
StringBuilder qlString = new StringBuilder("SELECT g FROM UserEntity as g");
...........................
我错过了什么?
也试过
@PersistenceContext(name = "keycloak") private final EntityManager entityManager;
繁花不似锦
梦里花落0921
撒科打诨
相关分类