How to deploy Spring Boot MVC project for others to see? - spring-boot

I've made a spring boot project called student-management using spring MVC, Thymeleaf, spring data JPA and MySql. When I run it locally on localhost:8081 it works perfectly. I made CRUD operations so I see all the changes in database when changed on the website and vice versa.
Now, I need to get my website "out there" for others to see, specifically a company. I'm new to Spring boot and everything that goes with it but I don't understand how to deploy my rather simple website so the company can access it by not using localhost.
This is my project_hierarchy. As you can see it's quite simple.
This is my StudentController.java. I've used #Controller and maybe I should've used #RestController. If so, how do I change it to #RestController so that my website still works.
My thymeleaf html files students.html edit_students.html create_student.html

Deploying remotely means choosing a host (e.g. AWS), setting up infrastructure, deploying your executable JAR with dependencies, and running it on a server.
You'll need to set up a separate MySQL instance and connect your app to it. That means you'll set up the database server, create the database and schema, and start it up before your app starts.
You should be thinking about security and who should be able to access your app and data. Most developers who have only deployed locally tend to put off those considerations. I'd urge you to think about them sooner.
If your purpose is to provide access inside your company, only to employees, perhaps you'd be better off making your local machine available to others on the network OR choose a server that's already on your company network. You'll have to work with others to make that happen.

Related

Update for JavaEE application

Our application are built on Spring boot, the app will be packaged to a war file and ran with java -jar xx.war -Dspring.profile=xxx. Generally the latest war package will served by a static web server like nginx.
Now we want to know if we can add auto-update for the application.
I have googled, and people suggested to use the Application server which support hot deployment, however we use spring boot as shown above.
I have thought to start a new thread once my application started, then check update and download the latest package. But I have to terminate the current application to start the new one since they use the same port, and if close the current app, the update thread will be terminated too.
So how to you handle this problem?
In my opinion that should be managed by some higher order dev-ops level orchestration system not by either the app nor its container. The decision to replace an app should not be at the dev-ops level and not the app level
One major advantage of spring-boot is the inversion of the traditional application-web-container to web-app model. As such the web container is usually (and best practice with Spring boot) built within the app itself. Hence it is fully self contained and crucially immutable. It therefore should not be the role of the app-web-container/web-app to replace either part-of or all-of itself.
Of course you can do whatever you like but you might find that the solution is not easy because it is not convention to do it in this way.

best way to read a file in Spring Boot

I have a spring boot application that currently runs in embedded Tomcat. I have a file, states.csv, that I want to parse on startup and seed my states database table (I tried via liquibase but that refuses to work).
I put the file in resources/main/ and that appears to work fine. My question is, if I decided against embedded Tomcat in the future (say moving to AWS or a regular Tomcat), is this still the best location to keep files for use?
I don't want to code myself into a corner if there is a better way to do this.
This depends entirely on how you're reading the file. As long as you're grabbing it out of the classpath, you should be fine. (And I've run single-jar applications on both basic AWS VMs and Cloud Foundry on EC2 with no difficulty at all.)

Automatic, contained testing of a web app

I have a web application that uses Spring, Jersey (for REST) and Hibernate+PostgreSQL. I'm using REST Assured for the testing framework. I created a simple test case and it works as long as I run Tomcat with my war.
I have a few questions regarding isolation & automatic tests:
I don't want to run tomcat just for the test. I would like to embed an app server.
I want to isolate my DB calls so that I can test it in a clean, predictable way.
Any suggestions, tips, links etc. for these challenges will be awesome.
You could use embedded Jetty as an embedded application server. Check out this and this post for details.
What you most likely want in this case is to run the application with a Spring profile,
in which profile the only thing that changes is the datasource. You would likely want to use an in-memory database like H2 or HSQL. Chek out this and this post.

Deploying Multiple Grails Apps With Spring Security Against Same Oracle Database

I have an existing Grails app which includes the Spring Security Core, Spring Security UI and Searchable plugins running on Tomcat against Oracle.
I have a new Grails app which will utilize the same plugins. Both apps customize the Person (User) domain class with different fields.
When I tried to deploy the second app against the same Oracle Database as the existing app NONE of the Spring Security classes were created. As a secondary issue there appears to be an issue with the Searchable plugin trying to create indexes. Clearly an oversight on my part that trying to deploy this.
Does anyone have any experience with an issue like this? Any workarounds you can think of? The obvious choice to deploy the second app against a new instance of Oracle, but as you can imagine this is less than desirable. My fall back plan is to merge the two applications, although this would be a great deal of work. Any advice or thoughts would be appreciated.
Much Thanks
UPDATE:
Still unsure of why the second deployment did not work, I would up rolling both apps together in order to deploy.

Spring Single Sign On with the same domain

I have a multiple spring based web applications (Spring 3) running on the same Tomcat server instance, I would like to implement single sign on with out using CAS or any other thing because I only have one domain so it would be a real over kill.
Now I found Tomcat's single sign on valve attribute but I really don't know how to use it with spring correctly, I found a question here about it but really not much there for it.
Is the tomcat's method the best one ? and if it is how to do it correctly ?
What I Have So Far:
I have developed an application that should handle the log in for all the applications and will be on tomcat's root, but I can't transfer data between my applications.
Is there a way to make this application the center one ?
I am using MySQL,Hibernate,Tomcat,Spring MVC,Spring Security

Resources