Я новичок весной и изучаю основы весенней партии.
На основании начального обучения я могу запустить приложение с помощью JobRepository на основе карты, используя следующие аннотации:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
Теперь я пытаюсь использовать локальный postgresql (НЕ используя JPA).
Но это не удается с ошибкой ниже:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Файлы конфигурации приведены ниже:
pom. xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.spring</groupId>
<artifactId>hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>hello-world</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5100/helloworld
spring.datasource.username=someuser
spring.datasource.password=somepasswd
spring.datasource.driver-class-name=org.postgresql.Driver
# Added below 2 based on some other stackoverflow searches
spring.datasource.platform=postgres
spring.batch.initialize-schema=always
Обратите внимание, что я не хочу использовать JPA, поэтому не предусмотрена зависимость в pom. xml.
Основной класс:
package io.spring.batch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run(HelloWorldApplication.class, args);
}
}
Я пытался скомпилировать, перекомпилировать, сделать недействительными кэши и перезапустить (intellij), но, похоже, мое application.properties вообще не читается .
Локальный postgres работает, может подключить его через клиент (DBeaver / pgadmin) и командную строку.
Разве мы не можем запустить его без указания зависимостей JPA? Если мы можем, что не так в приведенном выше?
Прикрепление снимка структуры проекта и ошибки. 