私はこのアプリケーションの中にHibernateを実装するために、tutorialに従っています。しかし、私はそれに記載されているapplication.propertiesの読み方を知らない。私はdocも読んでいますが、それは言及されています:application.propertiesを使用してhibernateの設定を設定するためのスプリングブートの設定方法
- 現在のディレクトリのA/configサブディレクトリ。
- カレントディレクトリ
- クラスパスの/ configパッケージ
- クラスパスのルート
しかし、春ブーツとカレントディレクトリは何ですか?
私もではありません。次の依存関係(チュートリアル参照)を使用して、私の問題はそれらを使用して解決できますか?動作しませんチュートリアルで説明するように、単にSRC /メイン/リソースでapplications.propertiesを入れて、また
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
:依存関係の衝突を引き起こしています。
@Bean(name = "dataSource")
public DriverManagerDataSource dataSource() {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/hibernate");
driverManagerDataSource.setUsername("root");
driverManagerDataSource.setPassword("root");
return driverManagerDataSource;
}
しかし、私は、以前のコードを削除した場合、それは間違いなくapplications.propertiesを見つけることができません:
私は手動で(これは私が春のセキュリティを使用しているものである)次のように設定している場合 それは作業を行いますParameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found. - Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name' - Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans
誰もこの問題を解決する方法を知っているか、またはリードを持っていますか?ありがとう!
編集:
私が行ったことについてもう少し説明します。ここに私のプロジェクトのアーキテクチャです:
@Configuration
@EnableWebMvc
public class MvcConfiguration extends WebMvcConfigurerAdapter {
@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() {
SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();
Properties mappings = new Properties();
mappings.setProperty("ClassNotFoundException", "greeting");
mappings.setProperty("SQLException", "greeting");
mappings.setProperty("IOException", "greeting");
r.setExceptionMappings(mappings); // None by default
r.setDefaultErrorView("error"); // No default
r.setExceptionAttribute("ex"); // Default is "exception"
r.setWarnLogCategory("example.MvcLogger"); // No default
return r;
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
/* registry.addViewController("/accueil").setViewName("accueil");
registry.addViewController("/").setViewName("accueil");
registry.addViewController("/hello").setViewName("hello");
registry.addViewController("/login").setViewName("login");*/
registry.addViewController("/accessdenied").setViewName("accessdenied");
}
/* @Bean(name = "dataSource")
public DriverManagerDataSource dataSource() {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/ai_15");
driverManagerDataSource.setUsername("root");
driverManagerDataSource.setPassword("root");
return driverManagerDataSource;
}*/
}
:私は何を妨害してはならないWebMvcConfigurerAdapterを、持っているhttp://pastebin.com/fjrfKcVX
私が言ったように、私のポンポンはそれがここで、異なっていますそれとは別に、それは同一であり、Hibernateを妨害するものは何もありません。私はちょうどTestDAO.javaのように、すべての名前を「Test」と改名しました。
編集2:私のapplication.propertiesファイルに次の行を除いて、チュートリアルのものと同一である:
spring.datasource.url = jdbc:mysql://localhost:3306/hibernate
と呼ばれています。単に、チュートリアルで詳しく説明しているように、applications.propertiesをsrc/main/resourcesに入れても機能しません。助けていない。このチュートリアルでは、何をしたのかを理解するために行ったことを説明する必要があります。 –
多くの情報を追加するために私の質問を編集しました。要約すると、私の 'WebSecurityConfig'と私のpom.xmlです。 – Chuck
編集は私が恐れるのを助けません。チュートリアルで詳しく説明したように "application.properties"を使用したことを示していますが、それは動作しません。私たちはまだあなたがapplication.propertiesに置いたものを知らない。また、アプリケーションをデバッグモード( '--debug')で実行して自動設定レポートを取得することもできます。これは' DataSource'が設定されていなかった理由を示しています。 –