gpt4 book ai didi

java - 找不到亚马逊凭据方法

转载 作者:搜寻专家 更新时间:2023-10-31 08:28:20 25 4
gpt4 key购买 nike

所以我的下一个问题是这段代码。似乎找不到方法,我的眼睛也没有受过训练。在这方面有什么帮助吗?

package packeging;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.amazonaws.HttpMethod;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.auth.BasicAWSCredentials;
import org.apache.http.*;
/**
* Servlet implementation class Hashtastic
*/
@WebServlet("/Hashtastic")
public class Hashtastic extends HttpServlet {
private static final long serialVersionUID = 1L;
private final static String BUCKET_NAME = "idlatestingbucket";//http://s3.amazonaws.com/THESISDB/techy.jpg
private final static String FILE_NAME = "TestPicture/wallpaper-264411.png";
private final static String ACCESS_KEY = "Fakepass";
private final static String SECRET_KEY = "Fakekey";
/**
* Default constructor.
*/
public Hashtastic() {
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 1000);
Date expDate = cal.getTime();
out.println(expDate+"\n");

BasicAWSCredentials cre = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
AmazonS3 s3 = new AmazonS3Client(cre);
String url = s3.generatePresignedUrl(BUCKET_NAME, FILE_NAME, expDate, HttpMethod.GET).toString();
out.println(url);
out.close();
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

}

我收到这个 500 错误。它说它缺少一种方法。我的库中有 jar 和用于 eclipse 的插件。

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found
com.amazonaws.http.ConnectionManagerFactory.createThreadSafeClientConnManager(ConnectionManagerFactory.java:26)
com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:83)
com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:116)
com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:60)
com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:291)
com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:273)
packeging.Hashtastic.doGet(Hashtastic.java:48)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.

有什么帮助吗?

最佳答案

如果您的类路径中有错误版本的 httpclient jar,或者如果您的类路径中有该 jar 的多个版本(例如,同时具有 httpclient-4.0.1.jar 和 httpclient-4.1. 1. jar )。

它也可能是由另一个包含同一类的不同版本的 jar 引起的。例如,我知道 gwt-dev.jar 包含一个版本的 ThreadSafeClientConnManager。如果是这种情况,可以通过调整构建路径顺序将 httpclient.jar 放在 gwt-dev.jar(或其他导致问题的 jar)之前来解决问题。

关于java - 找不到亚马逊凭据方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11103325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com