gpt4 book ai didi

java - 应用程序中有两种不同的架构

转载 作者:行者123 更新时间:2023-11-29 20:55:24 27 4
gpt4 key购买 nike

我在我的网络应用程序中使用两种不同的架构。我的应用程序可以运行,但在编译过程中出现一些错误。如何配置我的应用程序以使用多个模式?

我的 bean :

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory
(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setDataSource(dataSource);
entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter);
entityManagerFactory.setPackagesToScan("base");
return entityManagerFactory;
}


@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setShowSql(false);
adapter.setGenerateDdl(true);
adapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect");
return adapter;
}

@Bean
public DataSource dataSource() {
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setUrl("jdbc:mysql://localhost:3306/sc1?characterEncoding=UTF-8"); //?characterEncoding=UTF-8
ds.setUsername("*****");
ds.setPassword("******");
return ds;
}

我的实体:

@Entity
@Table(name = "agents",schema="sc1")
public class Agent {}

@Entity
@Table(name = "agents",schema="sc2")
public class Agent2 {}

错误消息:

     ERROR SchemaUpdate:261 - HHH000388: Unsuccessful: alter table sc2.agents constraint FK_dhh7a26whpx1a7cqnh646turg foreign key (doc_id) references sc2.Docs (id)
ERROR SchemaUpdate:261 - HHH000388: Unsuccessful: create table sc2.agents (id bigint not null auto_increment)
2016-06-07 14:38:33 ERROR SchemaUpdate:262 - Table 'sc2.agents' already exists

等等

最佳答案

您的 sc2.Docs (id) id 列既不是主键也不是唯一键。

关于java - 应用程序中有两种不同的架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37678554/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com