How to connect SpringBoot (on Wildfly) to MySQL on openshift 3? - spring-boot

To put a SpringBoot application on openshift 3 the suggested route is by using the s2i of Wildfly. For the moment this is sufficient for me.
How can I conect SpringBoot (on Wildfly) to MySQL at openshift 3?
Please show how I can use environment variables and/ linking.
Do I need to prepare the maven file to produce SpringBoot as a war?

The free eBook at:
https://www.openshift.com/promotions/for-developers.html
Uses a Wildfly application and connects it to a database. See if that will work for your situation.

Related

How to make my spring boot application online on my domain?

I have recently learned how to work with Spring boot. Now, I have an application which works locally without any problem. Now, I would like to know how I can make it available as a website.
I have got a free web host from here and have followed the instructions to create a war file for my project. But I don't know what I should do with this war file and how I should use it to have my web page online.
In the meantime, my code is using Atlas Mongodb in it. Is using a database problematic? Should I consider something special for that?
Thanks in advance,
Shared hosting like 000webhost do not support Spring boot Hosting. As it was said earlier to host spring boot you have two choices either you host jar or war file. War is the traditional way of hosting it which needs Apache tomcat server and Jar is the Modern way which supports cloud based solutions. To host your solution you can create an account with AWS(Amazon web services) or GCP (Google Cloud Platform) and you will get free credits to use for a while or you can use Heroku(https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku) which is pretty much easier to use, its free also. For the database if you are using (https://www.mongodb.com/cloud/atlas) then you are good. All the best
If you are using Spring Boot, which have an embedded tomcat. You can just pack your project to a jar file, put the jar file to the server, and then simply execute it on the network interface that can connect to the outside world.
If you would like to pack your project as a war file, then you should first install the environment (application server) like tomcat, glassfish, jboss, etc. After that, you can deploy the war file on the application server.
Likewise, you should install the database server on your host, and edit the spring application.properties to let your spring application connect to the database.

Neo4J connection timed out in Spring Boot 2.2.4 but not in 2.0.5

I'm building a Spring Boot application with neo4j. I have an issue connecting to a deployed database when I'm running on Spring Boot 2.2.4. In an other project with Spring Boot 2.0.5 it works, but when I upgrade that project to 2.2.4 it also breaks with the same exception.
The weird thing is that it also works on 2.2.4 locally when using a local Docker image.
I get the following exception when I try to connect to a deployed neo4j instance in the cloud using an uri of the form bolt://35.xx.xx.xx:7687 AND on Spring Boot 2.2.4:
If I run my docker image and I change the connection uri to bolt://localhost:7687 it also works perfectly fine on Spring Boot 2.2.4.
Even in my gitlab CI/CD pipeline the test works fine using a service inside the pipeline, also with the same neo4j image.
This is my build.gradle:
And these are the versions effectively installed:
I also can always use browser to connect to my database that's why I assume that it has something to do with the versions instead of my cloud configuration.
Anyone any idea what I have to change on my configuration?
Thanks in advance!
We run following versions:
neo4j 3.5.14
Spring Boot 2.2.4
Java 11
EDIT 1
As someone proposed, I also setup a very simplistic example application (https://neo4j.com/developer/java/) using just the neo4j driver v4 with my GCP instance of Neo4J. This works perfectly fine.
EDIT 2
My application.properties looks like this:
spring.data.neo4j.uri=bolt://35.xxx.xxx.xxx:7687 # <- in prod
spring.data.neo4j.uri=bolt://localhost:7687 # <- in dev
spring.data.neo4j.uri=bolt://neo4j:7687 # <- in CI/CD
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=****
spring.data.neo4j.embedded.enabled=false
The different environments are splitted in seperate property files that set the spring active profile. Im always testing this with replacing the localhost one in the application-dev.properties to the public ip.
My final setup (and solution) was to use only following dependencies:
implementation 'org.springframework.boot:spring-boot-starter-data-neo4j'
implementation 'org.neo4j.driver:neo4j-java-driver-spring-boot-starter:4.0.0.1'
And use following settings in the properties file:
org.neo4j.driver.uri=bolt://35.xx.xx.xx:7687
org.neo4j.driver.authentication.username=neo4j
org.neo4j.driver.authentication.password=neo4j
org.neo4j.driver.config.encrypted=false
Encryption wasn't the problem, but the settings had to be set to org.neo4j.driver instead of the org.springramework.boot dependency. The springframework dependency is still needed to use #Query etc in the repositories, thats why I needed both.

How to use Jetty Quickstart in spring-boot?

Jetty's startup-time can be decreased by using it's ability to Quickstart.
I am using spring-boot, in special, my spring-boot project does not use the default Tomcat, but Jetty.
How can I use Jetty's Quickstart feature in a spring-boot (using Jetty) project?
I managed to to run my spring-boot application, as a dedicated webapp in a Jetty, which uses Quickstart (all done via docker).
It is not worth it. The described setup is still slower than using embedded-Jetty from within the application (the setup was of course even slower, not using Quickstart).

Spring Framework hosting

I am trying Java with Spring Framework for my own web project. I've asked some traditional JSP web hosting firms which supports Tomcat and they said they do not support Spring Framework. I am confused about this situation. What is the different requirements between JSP and Spring Framework? I was thinking both of them runs on JVM such as Tomcat and they do not need any difference things. Does Spring Framework need different jar files, or different software on server?
Building a Spring application results in a jar with an embedded webserver (most of the times tomcat, but you can change this in the pom.xml/build.gradle).
I used to host my Spring applications on a VPS or Amazon EC2 instance. Something like that. You can just install Java on it and run your jar. No extra installations of webservers needed.
Ok, let get it straight, just summarizing what have been said:
Use Spring MVC, without spring boot.
Use Spring Boot, and create a war file.

How to deploy fuse project in server?

I create one fuse project using Jboss developer studio with apache camel spring context..
Currently I am running my project in local machine in internal Jboss-eap of Jboss developer studio. Now i want to deploy my project in application server or container.
Please give me answer of below question :
1) What should i use : fabric8 or osgi?
2) What are the dependency need to add in pom.xml for deployment?
3) I have jboss-fuse-6.1.0.redhat-379 , as per my understanding it is container. For deploy my project in server should i required any application server like jboss-eap?
4) As i am using maven for dependency, should i need to copy my maven local repository to server?
I suggest to read the JBoss Fuse 6.1 documentation - there is a deploying into the container guide
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html/Deploying_into_the_Container/
As you have JBoss Fuse then its a container by itself, so you do not need JBoss EAP - its two different containers.
You can deploy from the Eclipse editor if you have the Fuse plugins installed (I think they are named integration stack). You can read how to install those plugins at the installation section from this page: http://tools.jboss.org/blog/

Resources