in Education by
I'm developing a Spring Boot application in which I'm integrating Amazon S3 service. This class is my repository to access the S3 bucket : public class S3FileRepository implements ImageRepository { private String bucket; private AmazonS3 s3Client; private ResourceLoader resourceLoader; public S3FileRepository(ResourceLoader resourceLoader, AmazonS3 s3Client, String bucket) { this.resourceLoader = resourceLoader; this.s3Client = s3Client; this.bucket = bucket; } private static String toS3Uri(String bucket, String imageName) { return String.format("s3://%s/%s", bucket, imageName); } @Override public Resource getImage(String name) { return resourceLoader.getResource(S3FileRepository.toS3Uri(this.bucket, name).concat(this.IMAGE_EXTENSION)); } using Spring Boot Autoconfiguration as suggested. So in my pom.xml, among other things, I've org.springframework.cloud spring-cloud-aws-autoconfigure 2.1.1.RELEASE org.springframework.cloud spring-cloud-aws-context 2.1.1.RELEASE Moreover I've an application.properties done like this: cloud.aws.credentials.accessKey= (mykey) cloud.aws.credentials.secretKey= (mysecret) cloud.aws.credentials.instanceProfile=true cloud.aws.region.static=eu-west-2 cloud.aws.stack.auto=false The problem: Everything works fine if i compile my project and then I simply run the JAR with java -jar target/myproject.jar, i correctly get the image that I ask for and everything is fine. Instead if I run the project with the IDE default mvn spring-boot:run when I try to get an image (present in the bucket) an Exception occour saying following: ServletContext resource [/s3://mybucket/test.jpeg] cannot be resolved to URL because it does not exist java.io.FileNotFoundException: ServletContext resource [/s3://mybucket/test.jpeg] cannot be resolved to URL because it does not exist So what I think is that it throws an Exception because it's like it goes inside the jar to look for something that match s3://mybucket/test.jpeg but I can't get why, and why it happens only running the project with mvn spring-boot:run and not running the jar. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You're likely hitting the spring-cloud-aws issue #384 whereupon the spring-boot-devtools dependency, which is activated when you start the application from the IDE, activates a different code path in resource loading. You can test whether you're hitting this issue by removing the spring-boot-devtools dependency from your pom.xml file, reloading the project in your IDE, and running the same test.

Related questions

0 votes
    This one has been bugging me for a while now. Is there a way I can stop Intellj IDEA from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I believe that i messed up with configuration but I cannot get where and how to fix it. Here you ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I believe that i messed up with configuration but I cannot get where and how to fix it. Here you ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    You need to ensure that Azure DNS can resolve names for your registered domain. What should you implement? A. An MX Record B. A Secondary Zone C. A CNAME Record D. Zone Delegation...
asked Nov 20, 2022 in Education by JackTerrance
0 votes
    How is India trying to resolve its differences with China? Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    In 1978, the United States held a conference at __________ to resolve the Arab-Israel dispute. (Camp David, Helsinki, Paris, Geneva) Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to build my app on a physical device. Each time I try to build I get the following ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I create a blank project whit expo init then I installed react-navigation whit npm install @react-navigation ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have created new controller in the project with gii but I am getting Not Found (#404) error when ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    As asked in this question, I also want to know how to resolve a conflicting git stash pop without ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I have created a branch named dev. I have done a pull request to send dev code to master, when I do ... to resolve these conflicts. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
...