Firebase in Spring boot gives error during initalization

后端 未结 1 591
深忆病人
深忆病人 2021-01-23 19:38

I\'m trying to set up Firebase in Spring Boot app. I\'m following the code snippets given in the documentation here. This is how my pom looks:

         


        
相关标签:
1条回答
  • 2021-01-23 19:59

    Not sure if you found the answer Raj

    I was about to get rid of this error by excluding a dependency pulled in by Spring Boot's configuration processor and (though I did not see this error anymore after excluding just the first) also exclude from Spring boot starter test (if used):

    <project>
      ...
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-configuration-processor</artifactId>
          <version>1.5.8.RELEASE</version>
            <scope>compile</scope>
            <exclusions>
              <exclusion> 
                <groupId>com.vaadin.external.google</groupId>
                <artifactId>android.json</artifactId>
              </exclusion>
            </exclusions> 
          </dependency>
        ...
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <version>1.5.8.RELEASE</version>
            <scope>test</scope>
            <exclusions>
              <exclusion> 
                <groupId>com.vaadin.external.google</groupId>
                <artifactId>android.json</artifactId>
              </exclusion>
            </exclusions> 
          </dependency>
        ...
      </dependencies>
    </project>
    

    Please note: I haven not tested this exact pom snippet because I am using gradle instead of maven, but this should be right.

    How I found this

    Reading your question and other answers, I began looking into potential issue with class JSONStringer in package 'org.json'. So I was thinking a version conflict of a dependency that depended on 'org.json'

    Running ./gradlew dependencyInsight --dependency org.json, I received:

    org.json:json:20160810 -> 20140107
    +--- com.google.cloud:google-cloud-core:1.7.0
    |    +--- com.google.cloud:google-cloud-storage:1.7.0
    |    |    \--- com.google.firebase:firebase-admin:5.5.0
    |    |         \--- compile
    |    +--- com.google.cloud:google-cloud-firestore:0.25.0-beta
    |    |    \--- com.google.firebase:firebase-admin:5.5.0 (*)
    |    +--- com.google.cloud:google-cloud-core-http:1.7.0
    |    |    +--- com.google.cloud:google-cloud-storage:1.7.0 (*)
    |    |    \--- com.google.cloud:google-cloud-firestore:0.25.0-beta (*)
    |    \--- com.google.cloud:google-cloud-core-grpc:1.7.0
    |         \--- com.google.cloud:google-cloud-firestore:0.25.0-beta (*)
    \--- com.google.firebase:firebase-admin:5.5.0 (*)
    
    (*) - dependencies omitted (listed previously)
    

    so only the google dependencies were using this package. I suspected that the issue wasn't a version conflict in the google dependecies, so I looked for conflicts that Spring may have with the org.json pacakage.

    Google search for 'Spring boot org.json' led me to a Github issue about conflicts with json library. The issue mentioned that for spring-boot-starter-test since "org.skyscreamer:jsonassert:1.4.0 is required, exclude com.vaadin.external.google:android-json:0.0.20131108.vaadin1."

    From that, I ran: `./gradlew dependencyInsight --dependency 'com.vaadin.external.google' which referenced 'spring-boot-configuration-processor'.

    0 讨论(0)
提交回复
热议问题