Spring boot Multi Module project, Rest Services and Web Application - java

we have a Spring boot App that is a Rest Service, it has several microservice to attend other app in our environment, but now we need to create a web app for administrative purpose, so we were thinking of expanding this project making it a multi module project so it can share the repository and other utilities that they will have in common.
the only thing we have concerns is about the spring security config, it is possible that each module has their own security config and still be a single executable jar?

You can make. Maven or Gradle multi-module project. Common code will be a module without executable. Then you can import that module in all the others.
Yes, different modules can have different security config class.

Related

How to configure a Spring Boot Application that uses tomcat and has a dependency to another Application uses tomcat

I have a Spring Boot application (App1) that uses an embedded Tomcat. To specify the Port I added server.port=8080 to the application.properties in my main application
and it works fine.
Now I add a dependency to another Spring Boot application (App2) in the pom.xml (because in App1 I need access to the Beans from App2). App2 uses also an embedded Tomcat on a different port.
But when I run App1 it crashes because App2 want to also use the same server.port and configurations - that obviously cannot work.
Is this even possible what I want to achieve? And how would I do this that I can run both App2 in App1? If this is not possible, is it possible to access the Beans from App2 in App1?
I see two options, depending on which one suits your use case conceptually:
you have two Spring Boot applications that need to share the same code: extract this code to a separate project (a regular Java library), build it as a jar file and include into both projects as a dependency; an example could be found in the Creating a Multi Module Project guide;
you have two Spring Boot applications, one of them needs to access the functionality of another: provide and access this functionality as an API, instead of directly importing the beans. There are multiple ways to do this. For example, you could expose the bean functionality as a REST API using Spring's #RestController, and access them from the other side using RestTemplate. See the following guides: Building a RESTful Web Service, Consuming a RESTful Web Service

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.

jars required for REST service using spring

I am trying to implement a REST services using spring. I have added below JARS in the WEB-INF/lib and in Build path as well.
Spring core
Spring web
Spring MVC
Spring Context
Spring aop
Spring aspects
Common loggin
JSTL.
I have integrated the server in my Eclipse and started. When i try to hit the URL given in Spring controller, I am getting Resource not found Error. Exception I ma getting is ClassNotFound.
In the same project i have a HTML page when i try to hit it, its working fine.
Any jar i have to import or what may be the possible reason?
Have you explored SpringBoot? It is much easier to implement a REST based service. There are just 3 or 4 dependencies. You can find an example to implement a REST service here http://projects.spring.io/spring-boot/#quick-start
Search for the class using some utility like http://findjar.com and make sure that required dependency has been included in your project.
Do mvn dependency:tree to make sure that the respective project has been included.
If the respective project has been included, make sure that the class is there in the included version of the project.

From GAE to Cloudfoundry

I'd like to know the main differences between CloudFoundry and Google App Engine for a personnal project.
I have a web application that currently runs on GAE and i'am thinking to move it to CloudFoundry for various technical reasons.
I'd like to use :
Spring MVC & Spring Security.
a full implementation of JPA instead of DataNucleus.
mavenize my project properly, i can't make the maven-gae-plugin works.
Is CloudFoundry a good alternative to GAE in my case?
What is the complexity of the migration?
Thanks
It shouldn't be too hard to migrate the app.
http://blog.springsource.org/2011/11/10/using-cloud-foundry-services-with-spring-part-4-%E2%80%93-spring-profiles/ and the whole series of articles has lot of details on how to bind your Spring app to a cloudfoundry data source.
http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-maven/ has details about the cloudfoundry maven plugin, for deployment
To migrate your data, you may want to use the remote api http://code.google.com/appengine/docs/java/tools/remoteapi.html or bulkloader to export, then CloudFoundry Caldecott to import your data in CloudFoundry http://blog.cloudfoundry.com/post/12928974099/now-you-can-tunnel-into-any-cloud-foundry-data-service
http://start.cloudfoundry.com/frameworks/java/spring/spring.html the getting started in cloudfoundry for spring is a good place to start learning about deploying spring apps to cloudfoundry.
I hope this helps.
I can only answer the maven part: see this for a working multimodule example: https://github.com/leanengine/LeanEngine-Server
you must use it like this:
mvn gae:unpack // downloads GAE classes to your maven repo
mvn clean install package
cd lean-server-example
mvn gae:execute // starts a local server

How to integrate EJBs, Spring, Vaadin into an Enterprise Project

I want to create an enterprise project (with EAR packaging) with following modules:
1.) I want to have my Spring beans in the EJB module.
2.) The Vaadin application should be the web module.
Now I have everything in one web project. I have the spring bean configuration in the applicationContext.xml. In the web.xml the application context is configured to get loaded. How can I move the spring beans and the context configuration into the EJB module and deal only with the Vaadin UI in the web module, having the beans automatically injected into my custom components? Thanks for your help.
Consider the Spring Stuff Vaadin add-on for help with Spring and Vaadin.
Disclaimer: I'm the author

Categories

Resources