Can't call public method of non-public class: public (Google gcloud library)

前端 未结 4 904
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 13:46

I am attempting to use the gcloud library.

(ns firengine.state
  (:import
   [com.google.cloud AuthCredentials]
   [com.google.cloud.datastore DatastoreOpti         


        
4条回答
  •  清酒与你
    2021-01-06 14:38

    Completely inspired by hironroy's answer, I worked through an isolated example of getting this working. Created the file below in src/gcloud/GcloduDatastore.java in the following github project.

    package gcloud;
    
    import com.google.cloud.AuthCredentials;
    import com.google.cloud.datastore.Datastore;
    import com.google.cloud.datastore.DatastoreOptions;
    import com.google.cloud.datastore.DatastoreOptions.Builder;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    public class GCloudDatastore {
    
        public static Datastore getDatastore() throws FileNotFoundException, IOException {
            DatastoreOptions.Builder optionsBuilder = DatastoreOptions.builder();
            FileInputStream authStream = new FileInputStream(System.getenv("SERVICE_ACCOUNT_DOT_JSON_PATH"));
            AuthCredentials creds = AuthCredentials.createForJson(authStream);
    
            return optionsBuilder
                .authCredentials(creds)
                .projectId(System.getenv("PROJECT_ID"))
                .build()
                .service();
        }
    
    }
    

提交回复
热议问题