我正在Spring启动POC,mysql JPA和ElasticSearch。我正在配置配置所需的所有东西。现在我可以用elasticsearch执行CRUD操作,mysql也创建表但不保存值。我将如何解决这个问题。
这是我的pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.github.vanroy</groupId>
<artifactId>spring-boot-starter-data-jest</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
application.properties文件:
spring.data.elasticsearch.properties.path.home=target/elastic
spring.data.elasticsearch.properties.transport.tcp.connect_timeout=120s
spring.data.jest.uri=http://localhost:9200
spring.datasource.url= jdbc:mysql://localhost:3306/employeedb
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
我还创建了两个存储库并使用注释
@SpringBootApplication(
scanBasePackages={"com.example"},
exclude = {ElasticsearchAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class})
@EnableJpaRepositories(basePackages ="com.example.jpa")
提前致谢