MVN WebApplication Template with Spring Securing + Hibernate - java

I am looking for a mvn project template that can be downloaded and used as a kick-off for a web application.
The requeriments are:
Spring security (for user authentication and pages accesing control)
Hibernate integration (for data persistance like users and more)
The application must run on tomcat (i use TomEE)
I have a web application already running with pages and servlets and daos, persistence.xml and more. The problem is that i cant find the way to integrate this app with spring security, and for this reason i am looking for a project template...

Give Spring Boot a shot. You can either use Spring Tool Suite or Spring Initializer site to get a secure web app running and using hibernate as ORM.
You can later choose to run the app in the embedded Tomcat/Jetty or package as WAR and deploy in container of your choice.

Related

Integrating Camunda webapps in spring framework

I setup Camunda in my Spring 3 project (Tomcat server) using this guide. I embedded the workflow engine in my project.
However, I cannot access the cockpit when I go to the url http://localhost:8080/camunda/app/. I get a 404 error.
I see that there is a dependency to be added in case of Spring boot according to this guide
But I see no such dependencies available for Spring. Do we not get access to webapps while integrating Camunda with Spring?
Also asked this question in the camunda form: https://forum.camunda.org/t/integrating-camunda-webapps-in-spring-framework/27661
You'll need the following dependency.
<dependency>
<groupId>org.camunda.bpm.webapp</groupId>
<artifactId>camunda-webapp-webjar</artifactId>
</dependency>
Then ensure you have the required configurations. Refer the spring boot auto configuration set up here and the web app initialiser here.

Is it possible to make a Spring MVC web app run as a "standalone executable" with Java and Tomcat embedded?

I have a web app built with Java, Spring MVC, and JDBC. The result is a WAR file.
To run it, the user has to install Java 8 JDK and Tomcat, and deploy the WAR file to the Tomcat server.
It would be great if they could just download the one file run it as a standalone application.
That is, run "the WAR file" and just browse to http://localhost:8080/myapp
Also, on Windows it would be great it was setup as a Server (like Tomcat is when installed with the installer).
Is there any way to do this? Maybe with Spring Boot or something new like that?
Yep, Spring boot is the way to go.
It allows you to build an executable Jar with all dependencies and a Tomcat (by default, can be changed) embedded.
But users will still need to download a JRE to execute the Jar, and a database if it's required, but you can use en embedded database like H2, HSQLDB..., depends what is your needs.
Yes . you can use spring boot to achieve your results. Kindly refer the below link for sample code
https://mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/
You can use embedded jetty server using maven but that would require you to setup few things your app and may have align your existing app, please check this article for more information.
Jetty is similar to tomcat server in terms of running spring application, there are not much difference in terms of development. Tomcat is just more famous.
Other option as others said, is to migrate your app to spring boot which would be easy if you already have app written in spring (But that depends how much code you have and how much time you have)

Why do we need an application container when deploying a Spring Boot app to Openshift

It maybe a trivial question for experienced web application developers, but for me as a new developer, I cannot understand that why do we need an application container(like Tomcat or Wildfly) when deploying a Spring Boot web application to Openshift, Heroku, or Google App Engine, etc? My understanding is that Spring Boot already contains an embedded container (Tomcat). Can someone explain this to me? Thanks
SpringBoot is Java API that relies on an embedded Java Servlet engine to support the API calls. These dependencies are typically pulled in by Maven as dependencies. So for the end user, it just looks like a FAR JAR with a bunch dependencies included (where one of those dependencies is Embed Tomcat, Jetty or Undertow for example)
More information can be found on the main SpringBoot project page.

Adding Spring Boot's CRaSH shell to regular non-boot Spring MVC application

Spring Boot comes with a neat remote monitoring shell (http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-remote-shell.html) that's installed into Spring Boot apps by adding spring-boot-starter-remote-shell dependency. It provides access to Spring beans, jdbc, allows extension by custom commands, plugs into Spring Security for authentication, you can connect to it via SSH etc...
I would really like this feature in my regular non-boot Spring MVC application. I've searched the internet and Spring docs and found nothing. Any ideas how to achieve this besides reverse engineering spring-boot-starter-remote-shell sources?

Embedded Jetty and Spring Web MVC

For a pet project I would like to have an embedded Jetty run a Spring Web MVC app. I've used Spring in web containers (where it's easy to tell "where to start") and I've used embedded Jetty without Spring.
It feels a bit like the chicken or the egg problem if I want both to work together. What is the best way to organize the project? In other words, what shall I put in main()? Should it be a Spring app that happens to have Jetty as a bean (what about contexts then?)? Or should I start Jetty alone and plug Spring in via servlet listener? What are the caveats?
Jetty in a Spring container is used to start webapp, springified or not. The webapp and your webapp don't have the same Spring context without tricks.
So, you have to create a Jetty server in your main, add your webapp and start the server. The best way is using a web.xml like a common Java EE server, and add this descriptor to your Jetty server.
I think it is more reasonable to start Jetty alone and plug Spring in via servlet listener in web.xml. Let Spring manager all the app specific beans and let jetty focus on running your app, and maybe some day you can deploy you app to antoher servlet container without changing anything.
This is one way to embed Jetty in Spring
http://www.springbyexample.org/examples/embedded-spring-web-services.html

Categories

Resources