Java Google Books API-找不到密钥库JKS实现
我正在尝试使用GoogleBookAPI。然而,我不断得到错误: “找不到密钥库JKS实现” 该代码直接取自GoogleBooksAPI示例,并且(根据)该问题似乎与GoogleNetHttpTransport.newTrustedTransport()有关 但是,在该线程上尝试使用答案所建议的AndroidHttp.newCompatibleTransport()将不起作用 我找不到该类的正确导入,因为com.google.api.client.extensions.android.http似乎无效 这是我的密码:Java Google Books API-找不到密钥库JKS实现,java,android,google-books,Java,Android,Google Books,我正在尝试使用GoogleBookAPI。然而,我不断得到错误: “找不到密钥库JKS实现” 该代码直接取自GoogleBooksAPI示例,并且(根据)该问题似乎与GoogleNetHttpTransport.newTrustedTransport()有关 但是,在该线程上尝试使用答案所建议的AndroidHttp.newCompatibleTransport()将不起作用 我找不到该类的正确导入,因为com.google.api.client.extensions.android.http似
public static void queryGoogleBooks(JsonFactory jsonFactory, String query) throws Exception {
//Set up book client
final Books books = new Books.Builder(GoogleNetHttpTransport.newTrustedTransport(), jsonFactory, null)
.setApplicationName("Books++")
.setGoogleClientRequestInitializer(new BooksRequestInitializer(ClientCredentials.API_KEY))
.build();
List volumesList = books.volumes().list(query);
//Execute
Volumes volumes = volumesList.execute();
if (volumes.getTotalItems() == 0 || volumes.getItems() == null) {
System.out.println("No matches found.");
return;
}
// Output results.
for (Volume volume : volumes.getItems()) {
Volume.VolumeInfo volumeInfo = volume.getVolumeInfo();
Volume.SaleInfo saleInfo = volume.getSaleInfo();
System.out.println("==========");
// Title.
System.out.println("Title: " + volumeInfo.getTitle());
// Author(s).
java.util.List<String> authors = volumeInfo.getAuthors();
if (authors != null && !authors.isEmpty()) {
System.out.print("Author(s): ");
for (int i = 0; i < authors.size(); ++i) {
System.out.print(authors.get(i));
if (i < authors.size() - 1) {
System.out.print(", ");
}
}
System.out.println();
}
// Description (if any).
if (volumeInfo.getDescription() != null && volumeInfo.getDescription().length() > 0) {
System.out.println("Description: " + volumeInfo.getDescription());
}
// Ratings (if any).
if (volumeInfo.getRatingsCount() != null && volumeInfo.getRatingsCount() > 0) {
int fullRating = (int) Math.round(volumeInfo.getAverageRating().doubleValue());
System.out.print("User Rating: ");
for (int i = 0; i < fullRating; ++i) {
System.out.print("*");
}
System.out.println(" (" + volumeInfo.getRatingsCount() + " rating(s))");
}
// Price (if any).
if (saleInfo != null && "FOR_SALE".equals(saleInfo.getSaleability())) {
double save = saleInfo.getListPrice().getAmount() - saleInfo.getRetailPrice().getAmount();
if (save > 0.0) {
System.out.print("List: " + CURRENCY_FORMATTER.format(saleInfo.getListPrice().getAmount())
+ " ");
}
System.out.print("Google eBooks Price: "
+ CURRENCY_FORMATTER.format(saleInfo.getRetailPrice().getAmount()));
if (save > 0.0) {
System.out.print(" You Save: " + CURRENCY_FORMATTER.format(save) + " ("
+ PERCENT_FORMATTER.format(save / saleInfo.getListPrice().getAmount()) + ")");
}
System.out.println();
}
// Access status.
String accessViewStatus = volume.getAccessInfo().getAccessViewStatus();
String message = "Additional information about this book is available from Google eBooks at:";
if ("FULL_PUBLIC_DOMAIN".equals(accessViewStatus)) {
message = "This public domain book is available for free from Google eBooks at:";
} else if ("SAMPLE".equals(accessViewStatus)) {
message = "A preview of this book is available from Google eBooks at:";
}
System.out.println(message);
// Link to Google eBooks.
System.out.println(volumeInfo.getInfoLink());
}
System.out.println("==========");
System.out.println(
volumes.getTotalItems() + " total results at http://books.google.com/ebooks?q="
+ URLEncoder.encode(query, "UTF-8"));
}
任何帮助都将不胜感激
谢谢,试试看
替换
GoogleNetHttpTransport.newTrustedTransport()
与
新ApacheHttpTransport()
不完全清楚为什么会有人投反对票?
java.security.NoSuchAlgorithmException: KeyStore JKS implementation not found