GAE-没有为此线程注册任何API环境

问题描述 投票:0回答:1

我有一个使用Google App Engine部署到Google Cloud的spring-boot应用程序。有一个具有多个实体的数据存储。当我尝试通过我的应用程序检索数据(应用程序上载到appengine而不是本地)时,它总是抛出错误-

发生意外错误(类型=内部服务器错误,状态= 500)。没有为该线程注册任何API环境。

我正在尝试使其以这种方式工作:

@Bean
public FirebaseAuth firebaseAuth() throws IOException {
    ClassLoader classLoader = this.getClass().getClassLoader();
    InputStream
        serviceAccount = classLoader.getResourceAsStream("downloaded-key-270620-2a16da8f4062.json");
    FirebaseOptions options = (new Builder())
                                  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                                  .setDatabaseUrl(
                                      "https://my-app.firebaseio.com")
                                  .build();
    FirebaseApp.initializeApp(options);
    return FirebaseAuth.getInstance();
}

private Result<Product> list(boolean wholesale, String startCursorString) {
    FetchOptions fetchOptions = Builder.withLimit(10);
    if (startCursorString != null && !startCursorString.equals("")) {
        fetchOptions.startCursor(Cursor.fromWebSafeString(startCursorString));
    }

    Query query = (new Query("Product")).setFilter(
        new FilterPredicate("wholesale", FilterOperator.EQUAL, wholesale))
                                        .addSort("name", SortDirection.ASCENDING);
    PreparedQuery preparedQuery = this.datastore.prepare(query);
    QueryResultIterator<Entity> results = preparedQuery.asQueryResultIterator(fetchOptions);
    List<Product> resultBooks = this.entitiesToObjects(results);
    Cursor cursor = results.getCursor();
    if (cursor != null && resultBooks.size() == 10) {
        String cursorString = cursor.toWebSafeString();
        return new Result(resultBooks, cursorString);
    } else {
        return new Result(resultBooks);
    }
}

public void configure(WebSecurity web) throws Exception {
    web.ignoring()
       .antMatchers(HttpMethod.GET, new String[] { "/products" })
       .antMatchers(HttpMethod.GET, new String[] { "/purchases/update" })
       .antMatchers(HttpMethod.GET, new String[] { "/purchases/statistics/**" });
}

任何想法可能是什么问题?

firebase google-app-engine google-cloud-firestore google-cloud-datastore
1个回答
0
投票
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
© www.soinside.com 2019 - 2024. All rights reserved.