セルジュ:
私はいくつかの単純なアプリケーションを持っている、と私は、このクラスに問題がある(それは一部のみです)
import javax.sql.DataSource;
@Repository
@Transactional
public class AppUserDAO extends JdbcDaoSupport {
@Autowired
public AppUserDAO(DataSource dataSource) {
this.setDataSource(dataSource);
}
ここでのbuild.gradleは以下のとおりです。
plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.2.4.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
私は私のアプリを起動すると、私は次の取得します:
Description:
Parameter 0 of constructor in com.example.demo.dao.AppUserDAO required a bean of type 'javax.sql.DataSource' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
The following candidates were found but could not be injected:
- Bean method 'dataSource' in 'JndiDataSourceAutoConfiguration' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' in 'XADataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:
Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.
私は春に新たなんだと私は何をすべきかを理解して傾けます。
(その必要があれば)、PSまた、ここではデータベースのための私のapllication.propertiesです。私はなぜ知らないけどpostgresql.Driverは間違いのように赤と強調しました。
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=12345
PPS私は同様の問題といくつかの他のトピックを読んで、それが私を助けていませんでし。
ヨーゼフ:
build.gradle
2つの依存関係が欠落しています。
- org.springframework.boot:春・ブート・スターター-JDBC - のTransactionManagerを取得するために、データソースなど
- org.postgresql:PostgreSQLは - PostgreSQLのドライバをロードするためには、