小编Abh*_*ore的帖子

Amazon S3 Put Object 403 Forbidden 错误

我尝试使用客户端 SDK 直接上传到 Amazon S3 存储桶。我的代码基于这篇文章:http : //www.cheynewallace.com/uploading-to-s3-with-angularjs/。我可以使用 S3 控制台上传和查看文件。但是,当我尝试从客户端执行 putObject 时,出现 403 错误。请帮我弄清楚我哪里出错了。

CORS 设置:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
        <ExposeHeader>x-amz-request-id</ExposeHeader>
        <ExposeHeader>x-amz-id-2</ExposeHeader>
        <AllowedHeader>*</AllowedHeader>
        <AllowedHeader>x-amz-acl</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

2. Bucket Policy 


    {
        "Version": "2012-10-17",
        "Id": "Policy1460109621028",
        "Statement": [
            {
                "Sid": "Stmt1460109523730",
                "Effect": "Allow",
                "Principal": "*",
                "Action": [
                    "s3:PutObjectAcl",
                    "s3:PutObject"
                ],
                "Resource": [
                    "arn:aws:s3:::zxcvbucketdemo123/*",
                    "arn:aws:s3:::zxcvbucketdemo123"
                ]
            }
        ]
    }

3. IAM policy



 {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "s3:*",
          "Resource": …
Run Code Online (Sandbox Code Playgroud)

amazon-s3

5
推荐指数
1
解决办法
8628
查看次数

Spring-Boot-jdbcTemplate 对象未初始化

我是 Spring Boot/MVC 的初学者。我一直在尝试构建一个非常基本的示例来查询包含医生主数据的表。但是我反复收到“java.lang.NullPointerException”。很可能是因为 jdbcTemplate 对象没有被初始化。其他一些用户也遇到了这个问题,但是在他们的情况下,问题是在包含 starter-jdbc jar 或删除使用 new 运算符来创建 jdbctemplate 对象后解决的。我已经在我的代码中考虑了这些建议。对此事的任何帮助将不胜感激。我的代码片段如下:

1. application.properties :

server.port=8181

spring.datasource.url = jdbc:mysql://localhost:3306/my_sample_schema
spring.datasource.username = qwerty
spring.datasource.password = qwerty
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.driverClassName=com.mysql.jdbc.Driver
debug=true
Run Code Online (Sandbox Code Playgroud)

2.Test123Application.java

package com.example;
....all imports...

@SpringBootApplication
public class Test123Application extends SpringBootServletInitializer  {

  public static void main(String[] args) {
        SpringApplication.run(Test123Application.class, args);        
    }
}
Run Code Online (Sandbox Code Playgroud)

3.测试控制器.java

package com.example.controller;
 ....all imports...

@Controller
public class TestController {

    @RequestMapping(value = "/")
     public String  demofunction(){
      return "dummytemplate";
   }

    @RequestMapping("/default")
     public String demofunction2(Model model){
        Docrepo docrepo = new Docrepoimpl(); …
Run Code Online (Sandbox Code Playgroud)

spring-mvc nullpointerexception jdbctemplate spring-boot

3
推荐指数
1
解决办法
6894
查看次数