GAE - 没有为该线程注册 API 环境
GAE - No API environment is registered for this thread
我使用 google 应用程序引擎将 spring-boot 应用程序部署到 google 云。有一个包含多个实体的数据存储。
当我尝试通过我的应用程序检索数据时(应用程序上传到应用程序引擎,而不是本地)它总是抛出错误 -
出现意外错误(类型=内部服务器错误,状态=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/**" });
}
知道可能是什么问题吗?
我认为您可能没有根据 documentation 初始化它,它类似于:
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
我使用 google 应用程序引擎将 spring-boot 应用程序部署到 google 云。有一个包含多个实体的数据存储。 当我尝试通过我的应用程序检索数据时(应用程序上传到应用程序引擎,而不是本地)它总是抛出错误 -
出现意外错误(类型=内部服务器错误,状态=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/**" });
}
知道可能是什么问题吗?
我认为您可能没有根据 documentation 初始化它,它类似于:
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();