具有多个数据源的spring boot swing应用程序

时间:2017-04-02 19:14:06

标签: java spring swing spring-boot

我正在尝试构建一个独立的桌面弹簧应用程序,应用程序应该从多个数据源获取信息。我面临的问题是<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.css" rel="stylesheet"> <link href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css" rel="stylesheet"> <button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-1">Show Dialog (working)</button> <br /> <br /> <button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-2">Show Dialog (now working)</button> <br /> <br /> <p> Remember that the Dialog component requires the <a href="https://github.com/GoogleChrome/dialog-polyfill">Dialog polyfill</a> in order to function. It takes advantage of the native dialog element to provide the most robust experience possible. </p> <dialog id="dialog" class="mdl-dialog"> <h3 class="mdl-dialog__title">MDL Dialog</h3> <div class="mdl-dialog__content"> <p> This is an example of the Material Design Lite dialog component. Please use responsibly. </p> </div> <div class="mdl-dialog__actions"> <button type="button" class="mdl-button">Close</button> </div> </dialog> <script src="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.js"></script> <script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>@Autowired Repository Bellow是我的项目设置,我想因为应用程序是桌面我缺少一些配置

主要类

null

数据库配置 第二种配置方式相同。此外,IntelliJ显示@SpringBootApplication(exclude = HibernateJpaAutoConfiguration.class) public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class) .headless(false) .web(false) .run(args); } @Bean public Main frame() { return new Main(); } } bean无法自动装配

EntityManagerFactoryBuilder builder

存储库

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
    entityManagerFactoryRef = "notificationEntityManagerFactory",
    basePackages = { "org.thebot.notification.repository" })
public class NotificationDBConfig {

  @Primary
  @Bean(name = "notificationDataSource")
  @ConfigurationProperties(prefix="spring.notificationDatasource")
  public DataSource notificationDataSource() {
    return DataSourceBuilder.create().build();
  }

  @Primary
  @Bean(name = "notificationEntityManagerFactory")
  public LocalContainerEntityManagerFactoryBean notificationEntityManagerFactory(
      EntityManagerFactoryBuilder builder,
      @Qualifier("notificationDataSource") DataSource dataSource) {
    return builder
        .dataSource(dataSource)
        .packages("org.thebot.notification.domain")
        .persistenceUnit("notification")
        .build();
  }

  @Primary
  @Bean(name = "notificationTransactionManager")
  public PlatformTransactionManager notificationTransactionManager(
      @Qualifier("notificationEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
    return new JpaTransactionManager(entityManagerFactory);
  }

}

需要存储库的位置

@Repository
public interface NotificationRepository extends JpaRepository<Notification, Long> {
}

0 个答案:

没有答案