Merge Spring and Grails projects - java

We are developing an backoffice application using Spring and Maven as configuration manager. The project is moreless divided in two parts, and one of this parts is just for manage the data in the DB tables.
Now someone has discovered Grails, and with Grails this job is very easy, but we can't drop all the job and start a new project (the other part is fine as is).
With this, we are trying to merge both. We've configured maven grails plugin, and now we can get dependencies and run grails tasks, not perfect yet, but almost. The big problem we have is that the first part of the project (the Spring part) has a directory structure a bit different of the one wich uses Grails. We want to change de structure of the Grails part, but we really don't know how to do it. We suspect we must use some of (G)ant to change the directory structure with a script, but we've no idea of first, how to make the script, second, how to use it from Maven, and finally merging the two parts. The libraries of both parts are compatible, so it is posible that putting everything together the thing works.
I'm not waiting the answer but something related with the gant script and maven would be great.
As second question, has anyone tried to do something like this? (merge or expand a normal spring project with one grails project?)
Thanks all.

I found Mastering Grails a very good presentation of applications a little bit more complex than Hello World!.
"Slapping" a Grails application on top of existing Java classes is described in Grails and legacy databases.
HTH

You want the grails-app/conf/Config.groovy file.
In it, add or set grails.config.locations { } to the locations you want to merge the spring app with the main gails app.

Related

Is it possible to have a self-contained spring boot jar which can execute R scripts?

I have a spring boot + react application. The cool thing about spring boot is thus that it is able to run two different languages, namely Java and JavaScript anywhere without having to install many of the prerequisites like application or web servers.
My question is whether it is also possible to add a third language, namely R, such it is also completely contained in the JAR. And if yes is there any good framework and a tutorial?
There is a walkthrough of one such instance here: https://medium.com/graalvm/enhance-your-java-spring-application-with-r-data-science-b669a8c28bea
The demo application is found: https://github.com/graalvm/graalvm-demos
In order to complete this, you must download GraalVM and add it to the path. You will also have to download any necessary dependencies for the particular project you are doing.
As far as packaging it all as a JAR, I would assume it is possible since everything is done within the project.

Best way to generate maven modules

I have a complex structure of maven module with involves some like 20 modules for a standard application. The standard application is also supposed to contain spring xml files and packages folder setup from the start. Right now we are copying a example application and change the name all over it. But this seems like a lot of unnecessary work. I'm wondering what software would be best to use generate this.
I saw that maven had something for this called archetype but i'm not find much documentation and example on how to use it. Maybe there is better tool for this task.

Properly structuring a Java Spring framework project for multiple web applications

I am working on a project using the Java Spring framework, but I am (even after googling or looking through tutorials) unable to understand how it should be used.
Situation:
The project is(or, will be) made up of 3 separate web applications(for three different uses/target audiences) that uses the same database and to some extent functions and/or classes.
Database/cryptography-related classes and such are in a common folder under the project root, which seems appropriate.
Then there is a folder for gradle, used for starting the program("./gradlew app-one:bootRun"), which I suppose makes sense.
Then, there is a folder for one of the web applications("app-one") with related source code(Controllers, Services, etc.) and whatnot.
Problem:
I am tasked with adding the second application. Is it suppose to be a separate folder in the root directory?(Logically/By framework standards)
If it is not, how do I know what belongs to which application?
Do I need to use separate gradle commands to start each of the three applications? Is that even possible, and is it recommended/efficient/the best way to structure everything?
If you want to use maven,you can create a multi-module maven project with parent pom having all dependency management.A core project(jar) having all core functionality and three web projects(war) for your web modules which depend on this core project.You can start build and run these projects with a bat script from one place only.

xml-less spring configuration

I'm struggling with XML-less setup of a Spring project. Could you suggest some approaches to making this an iterative process? i.e. descirbe the steps of where to obtain configuration, how to find docs, which configs to define first, etc..
My goal is to implement a web app that supports websocket and I already found a very recent stock portfolio example https://github.com/rstoyanchev/spring-websocket-portfolio which works great, but when I try to create a simplest webapp that will have a very basic chat, I don't know where to start. I suppose this is all very new and not many are playing with this yet, but if you are, please share, I would be very grateful.
Update: My exact issue is how to dissect WebConfig java of the spring-websocket-portfolio project and rebuild it step by step to achieve a simple chat functionality. I have a spring project going, and it compiles and runs on tomcat 8 successfully(env is fine). the config file in question is this version: WebConfig.java.
What I am after is what is the best way to create something simple, a starting point, and build on top of it. By the way, the latest WebConfig.java has been much simplified by Rossen, but interestingly it has some compile issues and doesn't work.

Splitting Large GWT app into several modules

I have an app written with GWT and GAE where every supported city has its own app. Clearly this is not the best way to manage the map so I want to merge them all into one app. Currently my app is at the urls sub1.myapp.com, sub2.myapp.com, sub3.myapp.com, etc, and I want them to be at myapp.com/sub1 ,myapp.com/sub2, etc. All the supported cities share common code, so I'm going to put all the that code in one module, and have a different module for each piece of unique code block. Is this going about it the right way? How will the different modules interact?
Also, I currently have JSPs at sub1.myapp.com/listofsomesort and I would like to move these to myapp.com/sub1/listofsomesort. Is there a simple way to accomplish this?
By making a module with EntryPoint for each old application, in one and the same application. Each module has one 'welcome page' which you can put in different directories. All the shared code can go into another module. The shared code can be used by the inherit setting in other modules.
The only thing I bumped into was that when you deploy to GAE, ALL modules should have an entry point, also the library modules. I solved it by adding a dummy EntryPoint to them, that does nothing, but still searching for a better solution. See my question at How to deploy GWT Project containing GWT modules without entry points with Eclipse GAE plugin?.
This seems like the job for Code Splitting :) It might require some changes in the structure of your code, though - depends how tightly coupled your classes are. A compile report should tell you if your code splits up nicely, or if not, where the connections are.

Categories

Resources