Running spring-boot-maven-plugin Goals

In trying to follow a tutorial, he highlighted a few of the other Goals in the Maven build.

Goals Overview

The Spring Boot Plugin has the following goals.

from : https://docs.spring.io/spring-boot/docs/current/maven-plugin/index.html

I couldn’t see any of these in the pom.xml file, and the Maven Views in STS didn’t show them either. So, I created my own Run Configurations and specified the Goal manually using the documentation for the exact name.

Untitled

One way to start a new Git Spring Boot project

  1. Go to local git repository, create a new folder for your project
  2. On command line inside this new folder type >git init
  3. Open STS, Import > Git > Projects from Git > Existing local repository
  4. Pick your new git repository you just made, click Next
  5. Import using the New Project wizard
  6. Choose Spring Boot > Spring Starter Project.
  7. Copy all the contents of the newly created project to the local git repository manually using Windows Explorer etc.
  8. Commit the new files to the local repository.
  9. Push to remote repository on GitHub if required.
  10. Open STS, Import > Git > Projects from Git > Existing local repository.
  11. Pick your new git repository you just made, click Next.
  12. Import using the Import existing Eclipse Project.
  13. Run As > Spring Boot App, and all should be working.

There must be an easier way that manually copying… but you need to be in a Work-space to use the New Spring Boot project wizard.

Unable to find a region via the region provider chain. Again! Maven install in eclipse.

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.008 sec <<< FAILURE!
testLambdaFunctionHandler(com.backtojavaland.imageresizer.LambdaFunctionHandlerTest) Time elapsed: 8.923 sec <<< ERROR!
com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.

This is when following along the tutorial and trying to Run As.. > Maven install

I just can’t get it to work. It should be picking it up from the config file. So I tried adding an environment variable, adding something to settings.xml (although tbh I didn’t know what name to give it). Nothing worked, so I just disabled running tests for the install Run Configuration. At least I have my jar now.

No idea what’g going on!

Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region

Building Serverless Applications with Spring and AWS -Marc Thomas

Creating an Image Resizing Application

The first time I try to run something, it doesn’t work… surprise, surprise…

Anyway… I look online and it says that all the credentials should have been picked up from when I setup the CLI (Command Line Interface). I checked in Eclipse via Window > Preferences > AWS Toolkit, and it all seemed fine. I did set up a profile of awsdeveloper because I wanted to keep it separate from work aws stuff.

Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region. at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:436)#

Found the answer in the first stackoverflow question Google found:

“I solved this by adding the AWS_REGION environment variable. E.g. us-east-2. When using Eclipse, you can add this using the Run –> Run Configurations.”

As I was running a JUnit test, I updated the Debug Configuration. 😀

devtools not working

I used it before, everything was fine, but it seems that in running my application as a Java Project and not a Spring Boot Application from STS, it did not force a restart of the server.

I found this:

https://stackoverflow.com/questions/49386434/live-reload-not-working-in-spring-boot-devtools

“Developer tools are automatically disabled when running a fully packaged application.
If your application is launched from java -jar, you don’t use the spring-boot maven plugin to run your application.”

Updating greyed-out Maven dependencies in-between changes

https://crunchify.com/mavenmvn-clean-install-update-project-and-project-clean-options-in-eclipse-ide-to-fix-any-dependency-issue/

Saved my day. As I am following along with a tutorial, I’m adding to and changing an existing project. Things are bound to break during the changes, but my Maven test dependencies suddenly started to be greyed out, resulting in import errors in the auto-generated test class.

To fix this I just used Task 2,

  • Right click on Project
  • Click on Maven
  • Click on Update Project...

Fixed 😀

 

Gradle in eclipse pain

I tried to follow along with the videos in the O’Reilly Spring Boot introduction, but it was painful. I couldn’t get eclipse to notice the Path changes to use the JDK not the JRE, so couldn’t get things to build. The names have changed from buildRepackage to buildJar. I couldn’t get it to refresh to see the jar being generated etc.

A lot of this is due to my unfamiliarity with eclipse and gradle. It’s easy to find your way of doing things and stick with it, and not really become an expert in a tool even if you’ve been using it for years.

Anyway, I also followed along on the command line and managed to build and package a jar and war eventually.

It doesn’t seem to be working properly though as localhost:8080 returns an error. Oh well.

Anyway, to see the build folder, I had to deselect the Filter on the Package Explorer tab for the Gradle build folder. F5 referesh, and there it is 🙂

IDE

I’m following a guide to Spring and Spring Boot on the O’Reilly video guide supplied by Safari Online, and have downloaded the Spring Tool Suite and IntelliJ IDEA. I thought that if I had IntelliJ IDEA I’d be able to follow along with the examples, but it didn’t really work out. I’m not going to pay for my IDE when I’ve always used Eclipse anyway, so I upgraded from Oxygen to Photon and made sure I was using the new version of STS too, 3.9.5.