我已经完成了题为"以编程方式设置AWS区域1"的问题,但它没有提供我需要的所有答案.
Q1:我得到了SDKClientException-Unable to find a region via the region provider chain.我究竟做错了什么?还是我错过了一个错字.
public class CreateS3Bucket {
public static void main(String[] args) throws IOException {
BasicAWSCredentials creds = new BasicAWSCredentials("aws-access-key", "aws-secret-key");
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(creds)).build();
Region region = Region.getRegion(Regions.US_EAST_1);
s3Client.setRegion(region);
try {
String bucketName = "testBucket" + UUID.randomUUID();
s3Client.createBucket(bucketName);
System.out.println("Bucket Created Successfully.");
} catch(AmazonServiceException awse) {
System.out.println("This means that your request made it AWS S3 but got rejected");
System.out.println("Error Message:" +awse.getMessage());
System.out.println("Error Message:" +awse.getErrorCode());
System.out.println("Error Message:" +awse.getErrorType());
System.out.println("Error Message:" …Run Code Online (Sandbox Code Playgroud) 我在 MAC 上执行命令pip3 install awscli --upgrade --user并得到以下信息:
boto3 1.8.8 has requirement botocore<1.12.0,>=1.11.8, but you'll have botocore 1.12.160 which is incompatible.
boto3 1.8.8 has requirement s3transfer<0.2.0,>=0.1.10, but you'll have s3transfer 0.2.0 which is incompatible.
Run Code Online (Sandbox Code Playgroud)
我正在寻找解决方法。
提前致谢。
我知道静态内容首先被加载到内存中,但为什么在'CT'之前打印'IT'时我没有提到它是静态的?
class Person
{
Person()
{
System.out.print(" CP");
}
static
{
System.out.print("SP");
}
}
class Teacher extends Person
{
Teacher()
{
System.out.print(" CT");
}
{
System.out.print(" IT");
}
}
public class StaticTest
{
public static void main(String[] args)
{
Person p = new Teacher();
}
}
Run Code Online (Sandbox Code Playgroud) 我理解静态关键字的目的但遗憾的是我无法弄清楚这个简单的代码.不知道为什么?我期待答案非常简单.
public class VariableScope {
int x=y;
static int y=5;
public static void main(String[] args) {
System.out.println(new VariableScope().x);
}
}
Run Code Online (Sandbox Code Playgroud)
当y在早期分配给它时,x如何打印为5?
这是一个从.txt文件中读取所有内容的简单代码.不确定是什么问题.我尝试了一个不同的测试文件,它只读取了line2和line4 null.它甚至不应该null按照while循环条件读取.
import java.io.*;
import java.util.*;
public class FileInput {
public ArrayList<String> readFile() {
ArrayList<String> content = new ArrayList<>();
try {
File file = new File("input.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while (br.readLine() != null) {
line = br.readLine();
content.add(line);
System.out.println(line);
}
} catch (FileNotFoundException e) {
System.out.println("File could not be found. " + e.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
return content;
}
public static void main(String []args) {
FileInput …Run Code Online (Sandbox Code Playgroud) 已经有人问过类似的问题:在 conda 中解决包分辨率
Solving environment: /
Warning: 2 possible package resolutions (only showing differing packages):
- defaults/noarch::path.py-12.0.2-py_0, defaults/osx-64::path-13.2.0-py37_0
- defaults/noarch::path.py-12.4.0-0, defaults/osx-64::path-13.1.0-py37done
Run Code Online (Sandbox Code Playgroud)
已经尝试了以下方法:
conda update --strict-channel-priority --all
conda update --all
conda update anaconda
conda update conda
Run Code Online (Sandbox Code Playgroud)
似乎没有什么可以解决这个问题!将非常感谢任何帮助。
康达信息 ==> http://dpaste.com/2951Y1J
康达版本:4.8.3
conda 构建版本:3.18.11
操作系统:Mac OS 10.14 Mojave
TIA