I'm creating a web project using Spring MVC (with Maven). I would like to create three layers: DAL (myproject.dal), BLL(myproject.bll), PL (myproject.pl) (Presentation Layer). I've created three separated maven projects for all of these. Now I would like to create a main myproject.product WEB project, this will have all the mentioned projects as dependency.
The problem is that, I would keep all the web correlated files into the myproject.pl project, like web.xml, spring-bean-conf.xml, JSP files, etc.
When I run myproject.product on server it do not get the web.xml file. (All these files and folders are created with the correct structure in the myproject.pl.
So what I would like to do is to store the web.xml and the other web related files out of the web project.
Could somebody tell me what I'm doing wrong, it is it possible what I would do ?
Thanks for your help,
Have a nice day, Robert.
It's hard to say about "Can '3 Spring MVC projects' run in one MVC project ? ".
But i am using 2 different java projects in one MVC project.
I have three layer :
MVC
Process
Business
Create Spring MVC project. This is 1
Create two Maven-Plugin these are 2 and 3.
And add them in pom.xml like dependency.
I wish it's usefull for you.
Related
I'm using Intellij IDE Ultimate and I create a Project with spring inicializer. The problem is... now I need create more microservices (Spring Boot) but idk how to do this in IDE. I the end I need 3 microservices. Have a terminal command to create a new microservice inside my project? Or a way in the IDE to do this.
What you need to do is creating several modules (normally Maven modules), each of them is a SpringBoot application with its own application context and its own configuration, directories structure, etc.
IntelliJ has a concept of Module which matches very well the Maven module concept.
If you go to File, Project Structure, Project Settings, Modules you can see a very nice view of the current modules (in your case it should be only one). You can add or remove modules there. (Also by just clicking File-New Module, but the Project Structure View is more useful).
If you decide going the Maven way, you can also create your structure in disk and its POMs and import maven project in IntelliJ.
In any case, keep in mind that you will like to deploy every microservice as a separate and autonomous deployable unit.
I am trying to convert a normal monolithic web application into microservices structure using Spring Boot and Spring Cloud. I am actually trying to create Angular 2 front-end application and calls these my developed microservices in the cloud. And I am already started to break the modules into independent process's structure for microservice architecture.
Here my doubt is that, when designing the flow of control and microservice structure architecture, can I use only one single Spring Boot project using different controller for this entire web application back end process?
Somewhere I found that when I am reading develop all microservices using 2 different Spring Boot project. I am new to Spring and Spring Cloud. Is it possible to create all services in single project by using different modules?
Actually, it doesn't matter to package all those services into ONE project. But in micro-service's opinion, you should separate them into many independent projects. There are several questions you can ask yourself before transforming original architecture.
Is your application critical? Can user be tolerant of downtime while you must re-deploying whole package for updating only one service?
If there is no any dependency between services, why you want to put them together? Isn't it hard to develop or maintain?
Is the usage rate of each service the same? Maybe you can isolate those services and deploy them which are often to be invoked to a strong server.
Try to read this article Adopting Microservices at Netflix: Lessons for Architectural Design to understand the best practices for designing a microservices architecture. And for developing with Spring Cloud, you can also read this post Spring Cloud Netflix to know which components you should use in your architecture.
Currently I am working on microservices too, according my experience we have designed microservices as step below,
Maven
You should create the project with different project. But actually you can separate your project to submodule. So you will be easy to manage your project, the submodule you can use with other project too.
Build the Jar Library put your local repository. it can save your time, you have just find the same component or your functionality then build the jar file put in your local repository , so every project that use this function call point to download this repository, you don't have to write many project same same.
So finally I would like you to create different springboot project, but just create submodule and build local repository.
By creating your modules in different projects you create a more flexible solution.
You could even use different languages and technologies in a service in particular. E.g. one of your services could be NodeJS and the rest Java/Spring.
I'm starting writing a Spring/boot Angular 4 application and I have a small question. In the Angular 4 app we create a folder called LocalEvent (or something) which houses the module, controller, service, html template and css file. How would I create a structure for Spring?
I've seen Spring folder examples where everything is divided into /services /controllers. I understand that Java uses packages, so having 10 folders would mean having 10 packages which could get confusing fast. But I would like to hear from a few more experienced developers how they set up their Spring structure.
There is no Spring Boot structure as far as I know. The service and controller packages structure are the way how Java programmers architect their applications following the popular MVC pattern. Next, there is a Maven standard project structure where other Java or JVM based languages build tools follow
I need to deploy 2 packages to Wildfly:
1. EAR file - containing all server side (JavaEE) code.
2. WAR file - containing website code (HTML,JS,CSS...).
In order for the website path to be something like localhost:8080/somename/index.html, I need to specify <finalName>somename</finalName> in Maven. On the other hand, the EAR file contains the RESTful stuff, and in order for the REST to be under the somename context root I added the appropriate tag to maven-ear-plugin.
Now... I guess Wildfly doesn't like 2 things to be registered under same name, so I can't deploy the website.
What is the proper way to approach this problem? Combine the two projects under the same name and deliver only one package?? maybe change the context root of the EAR since it's "the RESTful voodoo stuff" that is not really important?
I would really want to register the two under the same context root but leave both projects separated.
You can't register two different WAR's under the same context. Since you want to leave the business logic separate from the UI it's probably best to register the WAR with your REST services under a different context.
I am working on a large scale system using PrimeFaces 5.0, Java EE 7, Maven 3.0.5, Netbeans 7.4 & GlassFish 4.0
I want to implement it as (multiple WARs , multiple EJBs , one EAR).
Multiple wars could have common files like (JS, CSS, XHTML, Backbeans & Converters)
i have achieved this using jar which contains this resources.
different WAR files, shared resources
I need a session-scoped bean to be shared between different wars, I found this but i found it more than what i need.
http://docs.oracle.com/cd/E18686_01/coh.37/e18690/glassfish.htm#CEGBDHJB
so my questions is:
Is using a jar is the right approach to share what i want ??
where do i put jars like primefaces or omnifaces in the project where they use the same class loader ??
How can i share session-scoped between different wars ??
I have been working on a ear project with similar requirements as yours, according to our experience :
Sure. We have seperated our war projects and use them as extended controllers to carry out front end logic and passing data to view, and they make their service calls via a jar file called common-services.jar . Our whole service layer is living on a single jar file. However if you ask my personal opinion, I think it would have made a lot sense to create a third war file just for the services, and talk restful with all the front-end repos. That way service calls could be opened to third party users without any further work. So to sum it all up, yes it is an acceptable approach, but you should also consider packing it as war.
On a parent pom above all war, so all war files use the same version and it is managed from a single pom.
Carry all session based operations to your third jar / war we have discussed in question 1. Makes much more sense that way. Or I suppose you will need solutions like single sign on. But my first suggestion works like a charm for us.