Spring boot basic guide: How to create complete folder? - java

I'm creating basic spring boot application as in this guide
If I download their completed-guide-code, I get the complete folder to run and test app.
But if I do practice as start from scratch, install prequisite, go to start.spring.io and config, generate starting project, create web app, create app class, and go to step Run the Application, I cannot find the folder complete as in guide, so I can't run and test app. Maybe I should run some build command to create it? So how to create it?

Please just run mvn spring-boot:run (use mvnw if maven is not installed or not on path. Spring boot project contains mvnw executable) in the project root without the directory specifier.
./ could be used for unix like systems but not windows.

complete folder is just the root project name in the guide. In your case, the root project name is spring-boot, go to spring-boot directory and run ./mvnw spring-boot:run.

Related

Deploy maven multi module project in GC

I'm new to google cloud and I need to deploy my java application there.
Currently it consists of 1 one web-module and directory structure looks like this:
clinic_project
acms-frontend
pom.xml
pom.xml
And start script:
#!/bin/bash
nohup mvn clean install
serv=acms-frontend
cd $serv
nohup mvn spring-boot:run -Dspring.profiles.active="dev" -DAUTH0_CLIENT_ID=".." -DAUTH0_CLIENT_SECRET=".." -DACMS_CRYPTO_KEY=".." -DACMS_NODE_NAME="n/a" -DACMS_POD_IP="n/a" -DACMS_POD_NAMESPACE="n/a" -DACMS_POD_NAME="n/a"
Inside web-module I have .yml file with default port and other variables.
I've installed gcloud SDK and understand how I can deploy single module application.
But how can I tell google cloud to deploy my multi-module project with commands sequence from script?
If you want to deploy multiple modules, you can do so with the following command: gcloud app deploy ~/my_app/app.yaml ~/my_app/another_service.yaml as mentioned in the gcloud app deploy documentation examples.
Make sure to add the module/service name in the app.yaml files as mentioned in this other document, otherwise you may run into some naming issues with them.
Hope you find this useful!

how to configure Wildfly to deploy Maven project

I'm learning Maven with eclipse and a liitle bit confused on how to deployed it on a remote server.
Before using Maven I created a web project and exported it as ear file and copied to the server's deployment folder. With Maven do I follow the same step? Do I need to install maven at wildfly server by modify the configuration xml? Thx.
Use maven only to produce artifacts(jar, war, ear). I was in the same position a couple of years back and found a useful link to build a project as an ear with maven.
For the remaining tasks, I coded Shell script to move the artifact from /target directory to wildfly10 \standalone\deployments.
It could also be achieved without any script using symbolic links.Just cd to your \standalone\deployments directory and:
ln -s [ABSOULUTE-PATH-TO-YOUR-WAR/EAR-FILE] [NAME-OF-EAR]
That's it. If you are more interested in symbolic links you may read here

Google Cloud App Engine deploy of java app fails

I'm trying to deploy sample java app (\java-docs-samples\flexible\helloworld) to my GCP App Engine project. Source is on my laptop, and I have built the project locally.
The error indicates a build is being attempted. I have also moved app.yaml to the project root directory - no help. All I need is for the .war file to be uploaded. Any ideas?
My command line to deploy:
gcloud app deploy src\main\appengine\app.yaml --project=my-real-project-name
From error log:
Pulling image: gcr.io/gcp-runtimes/java/runtime-builder#sha256:b279f7e1075a502c04115c15412df5616b9d0e6e9906ed6fc6e426e0bb9602ec
sha256:b279f7e1075a502c04115c15412df5616b9d0e6e9906ed6fc6e426e0bb9602ec: Pulling from gcp-runtimes/java/runtime-builder
Digest: sha256:b279f7e1075a502c04115c15412df5616b9d0e6e9906ed6fc6e426e0bb9602ec
Status: Downloaded newer image for gcr.io/gcp-runtimes/java/runtime-builder#sha256:b279f7e1075a502c04115c15412df5616b9d0e6e9906ed6fc6e426e0bb9602ec
Exception in thread "main" com.google.cloud.runtimes.builder.exception.ArtifactNotFoundException: No deployable artifacts were found. Unable to proceed.
at com.google.cloud.runtimes.builder.buildsteps.PrebuiltRuntimeImageBuildStep.getArtifact(PrebuiltRuntimeImageBuildStep.java:77)
at com.google.cloud.runtimes.builder.buildsteps.RuntimeImageBuildStep.run(RuntimeImageBuildStep.java:50)
at com.google.cloud.runtimes.builder.BuildPipelineConfigurator.generateDockerResources(BuildPipelineConfigurator.java:104)
at com.google.cloud.runtimes.builder.Application.main(Application.java:147)
You can try with mvn clean package appengine:deploy to clean the files and directories generated by Maven during its build.
The difference between the gcloud app deploy command and the maven deploy is that the maven builds and packages your app before deploying it and the gcloud command just deploys your application without packaging it. Also, the gcloud command requires you to specify the documents that you are going to deploy.
In the official documentation [1] [2] you can find more information about how to deploy your application using each command.
These are the steps to deplow to google cloud appengine flexible environment:
-Change your war file to jar. see docs below
https://cloud.google.com/appengine/docs/flexible/java/dev-java-only#prerequisites
-Put your jar file in the project root directory (projectName/file.jar).
-Run "gcloud app deploy" from your project directory. see documentation below
https://cloud.google.com/appengine/docs/flexible/java/dev-java-only#deploying_your_app

How to make SpringBoot project run through war package, and can also run through jar

I want my project to be launched on my personal computer via the Main function (either via java -jar or by mvn spring-boot: run), and when the development is complete, I can deploy it directly to Tomcat.
How to configure, to do this
You don't have to do anything special. Just follow the official documentation to build a deployable war. The war file created using the Spring Boot build process is executable as a regular jar file as it contains an embedded servlet container in a separate directory called lib-provided which is added to the classpath only when the war is directly executed.
Bonus: If you want to get rid of unnecessary dependencies on embedded server when creating a deployable war, you can check out a blog post, which show how to do it step-by-step.

Spring boot + angular 2 Heroku deployment

I have a big issue. I'm trying to deploy Spring Boot + Angular 2 web app on heroku but don't know how to do it. I tried several things including:
Making a .war file and deploying it to heroku (source here)
Deploying project as standard java application (source here)
but none of these worked. The first attempt didn't work because I constatly got 404 not found, and the second one didn't work due to, I think, some jar file wasn't found in the location which was described in the Procfile.
Can anyone give me a link, an example, or write a step by step instruction how to achieve this. Thank you.
The most simple way to do it:
run ng build in angular 2 project root (if you are using angular-cli) and copy the content of dist folder to src/main/resources/static/.
create Procfile (for maven):
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar
commit and push changes.
Also, you need spring-boot-starter-web present in dependencies. Which has embedded tomcat and automatically configured to serve static content from the static folder.
If you deploy your app as a standard Java application, you can combine it with the Node.js buildpack to run ng build during the Heroku build.
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/java
$ git push heroku master
The Node.js buildpack will detect your package.json, install Node.js and run npm. Then the Java build can proceed as normal.
There is a guide for doing something very similar but with Grunt: Using Grunt with Java and Maven to Automate JavaScript Tasks
Use JHipster: https://jhipster.github.io
Once installed, run:
$ yo jhipster
Then run
$ yo jhipster:heroku

Categories