spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Could not autowire. no bean of type FirestoreTemplate found #2610

Closed yustarandomname closed 3 years ago

yustarandomname commented 3 years ago

Describe the bug When trying to init firestore template, IntelliJ reports "Could not autowire. no bean of type FirestoreTemplate found". Is there a simple way to resolve this bug?

Using: 'org.springframework.boot' version '2.3.5.RELEASE' "org.springframework.cloud:spring-cloud-gcp-data-firestore:1.2.6.RELEASE" "org.springframework.cloud:spring-cloud-gcp-starter-data-firestore:1.2.6.RELEASE"

Sample Screenshot 2020-12-10 at 16 48 11

yustarandomname commented 3 years ago

tried to copy: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/blob/master/spring-cloud-gcp-samples/spring-cloud-gcp-data-firestore-sample/src/main/java/com/example/UserController.java

dzou commented 3 years ago

Can you share your pom.xml? I think that error means that you're not loading our Firestore autoconfiguration for some reason, may be missing a dependency.

Should look something like this:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.5.RELEASE</version>
    <relativePath/>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <name>Spring Cloud GCP Code Sample - Spring Data Firestore</name>
  <artifactId>spring-cloud-gcp-data-firestore-sample</artifactId>

  <!-- The Spring Cloud GCP BOM will manage spring-cloud-gcp version numbers for you. -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>spring-cloud-gcp-dependencies</artifactId>
        <version>1.2.6.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter-data-firestore</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
      <groupId>io.projectreactor</groupId>
      <artifactId>reactor-core</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>
meltsufin commented 3 years ago

Please re-open if you're still having this issue.