Spring Batch Admin - spring

I want to add a new menu to spring batch admin,
I have gone through the docs but not helpful, can anyone please help me with an example also where to put FTL files for that menu.
Thanks in advance

Your question is far too open ended.
HERE is an example of how to customize spring-batch admin.
Be advised that spring batch admin is at end of life and the last milestone release has quite a few issues in its POM dependencies. You'll need liberal use of maven exclude elements to get it to compile without a ton of dependency conflicts.
End Of Life Announcement
Per the above you should look into "Spring Cloud Data Flow" instead of spring-batch-admin. I have not used this yet, but the maven issues in the milestone release were a huge pain. Honestly I never did get it to work the way I wanted.
All that said your FTL files go in the webapp/WEB-INF/web directory tree.
Good luck

To add a menu in SBA, you need to develop following components:
A class that extends the BaseMenu (Class implementing the SBA menu interface).
A Controller class handling the request issued on click of you menu
A View bean
A Freemarker template implementing the view.
Template files are looked at WEB-INF/web. Place your template file under WEB-INF/web/ftl.

Related

Simple working Spring MVC / Maven configuration

I’ve been trying to set up a Spring MVC application from scratch, using Maven, in IntelliJ Idea. I know there are probably some nice Archetypes that can do this for you, but I really want to understand what’s going on. Here’s what I want to do:
Create a simple web application that shows displays “Hello World” under https://localhost:8080/, using an embedded Tomcat (with the Maven plugin). So, one controller, one request mapping, and one template. I’ve been able to get the spring application to boot (the Spring logo appears in the console) and Tomcat seems to run as well (the site responds). The problem is, I haven’t been able to get the request to map to my RequestMap method in my Controller. I’m quite sure that the controller isn’t the problem, but that it’s some configuration/setup issue.
Here’s the thing: I’ve been looking at tutorials, StackOverflow, Spring documentation, etc. for hours now, but I haven’t found a source that really explains how to configure a Spring MVC Maven project. Everyone seems to have a different opinion on what XML files you need, what they should be named, and where they should be located. The consensus seems to be that you need a web.xml file in a folder named WEB-INF, but even there, everyone has a different opinion on where that folder should go. I appreciate that there are multiple different ways to do this, and that there’s no “right” way, but in my experience, there are definitely many “wrong” ways =).
My question right now isn’t necessarily how to get my current project running (I don’t mind starting over), but what kinds of config files are out there (web, spring, app-config, servlet, …), what they do, which ones you need, where they need to go, what they should be named, how they connect, etc. Some people also use the Maven Compiler plugin, and others don’t, and nobody says why :D. Essentially: How do I let Spring know where to find controllers, templates, etc., and how to run and deploy all of this on the embedded Tomcat. I would like to find a source that explains the entire core-ecosystem of Spring MVC in a unified way. I have found many sources that provide “how-to” tutorials, but with little to no explanation (like “add the following servlet.xml file to your WEB-INF folder”). So, if your setup slightly differs from the tutorial (e.g. because you are using IntelliJ instead of Eclipse, Tomcat instead of Jetty, embedded Tomcat, a slightly different folder structure) nothing works, and, most importantly, you have no clue why.
Has anyone learned these setup-basics with anything better than copy/pasting or trial & error? :D
Easiest way to start is by using Spring Boot. Go to following link:
Spring initializr
Choose "Web" for "Selected Dependencise" and click "Generate Project". Download of maven project should start after that. Then import that project in IntelliJ IDEA as a Maven project. And that is a good starting point. You'll get main class that you can run and embeded Tomcat will start at 8080 port. Than you can add some controller, template etc...
Also good guides

Spring Batch using eclipse or STS

I am new to Spring Batch. I want to understand by making some simple Hello World or by reading a CSV file. On internet I saw many examples but everyone is explaining the code but nobody is talking about project structure or how to create project in eclipse or STS. Please provide me links which can explain the process very simple or share the articles for it.
You can download and import a simple Spring Batch project directly from STS:
Click: File -> New -> Spring Project
In the "New Spring Project" Window, under "Templates", expand the "Batch" folder.
Click on "Simple Spring Batch Project", provide aproject name and click the "Next" button.
That's it. The project has what I would call a simple spring and spring-batch standard setup. You can easily extend it by adding an ORM-framework or whatever you like ...
There is a guide providing exactly what you are looking for (how to structure the project, Maven/Gradle config, code, etc) on the spring.io web site:
http://spring.io/guides/gs/batch-processing/
It's generally a good idea to follow the tutorials on spring.io before following tutorials from anyone else.

Cannot proceed with Spring Roo: Advaned MVC Problems

I was scheduled to begin work on a new project and decided to make my life easier by adopting a new technology that I had no experience with: Spring!
Specifically Spring Roo, and therein lies my problem.
Spring Roo does so much auto-magical stuff that I really do not know how to proceed. As this runs the risk of turning into a rant, let me be more specific and then follow it up with my question:
Spring works great for setting up my classes and persisting them with Hibernate and all that. The main problem I am having is in trying to scaffold my project.
I am working on a project that manages a few "set" references with many-to-many and many-to-one relationships. This immediately will have problem with the scaffolding application.
Trying to add Google Web Toolkit via 'gwt setup' kills the application immediately. Trying to load in Tomcat server becomes impossible and there is no way to undo the process (as far as I know). Now what? I have to restart my project from the original commands and reapply my changes as far as I can tell.
With this being said it seems to me that the best process is to use ROO to generate my project artifacts and then create my own View/Controller setup. Even here I am having problems though, because the tiles configuration seems so obscured from how it works. I am having a hard time figuring out how to take a custom JSP that can process some of these complex many-to-one relationships (AJAX enabled) and add it to my web front.
Are there any guides for this?
FYI: in the existing Roo Generated MVC I tried
Copying over my JSP
Creating a Form Backing Objects that wraps the different entity types
Modifying the views.xml file in the folder to recognize the page
One this was accomplished, though, I have been unsure how to proceed. How do I access my JSP? Manually typing the URL as it is defined in views.xml does not work.
Should I think about abandoning Roo altogether and starting a Spring project from scratch?
Bet way to learn Spring Roo
read documentation (Spring Roo, enter link description here)
experiment with Roo and watch console output. See files that change, what changes if you add new controller etc.
read and discuss matters in SpringSource forum
follow spring-roo tag in SO
Using Spring Roo for scaffolding
user version control system or backup project. If result does not satisfies you - rollback changes.
Eclipse or SpringSource Tool suite have have hiccups (1, 2). Be aware of them. Use mvn eclipse:clean eclipse:eclipse and re-import project if necessarily.
know the difference between MVC architectural pattern, Web MVC framework and GWT scaffold application.
know limitations and behaviour of scaffolding (ITDs: GWT Style, Expected GWT Add-On Behaviour, JSP Views)
know how Validation, Data Binding, and Type Conversion works, to use effetely in your views
investigate request pipeline (Adding a custom page in spring roo, Adding new Activity in GWT scaffolded app)

How to separate spring contexts in intelliJ IDEA

I have a problem configuring IntelliJ IDEA for developing spring and maven powered application.
App has two separate spring configurations for production and test purposes. In spring facet props in IDEA I created two different file sets but when configuring one of contexts IDEA shows variants for both ones in code completion. How can I deal with this?
Thanks
Aleksander
The only option is to create two different filesets of spring config. If the beans are defined in both the filesets, it would links the beans to both filesets. Obviously I don't think it (or any IDE) is capable of resolving if it has to use main/test filesets based on your code path. Hope they would enhance the sprint context(fileset) resolution based on the code path (source/test). But it would be difficult for the IDE as the main business logic falls in both main/test context during the flow.
IDEA 2016.2 has checkbox: Check test files:
After check on IDEA stop complain, that test files not included in Spring Facet.
Try to play with it.

Easiest way to add GWT to a Spring MVC application?

I've got a Spring MVC application and I've decided that I'd like to try using GWT for the front end. I'd like to continue using MVC as I'll also be using Spring Security and some other springy stuff.
I'm aware of the GWT-SL project, and I guess I'll use it. The documentation is light on examples unfortunately.
What I'm wondering now is.... how do I reconfigure my project so that I can use GWT? I'm assuming that I'll lose the ability to run in hosted mode, and I suppose that's ok. Do I just add the GWT and GWT-SL jars, reconfigure my web.xml, and add a package to my project for the GWT code?
I'm using Eclipse 3.4. My existing project is standard web project.
With the new version of the GWT plugin, you'd have all the benefits of the hosted mode browser without having to modify any options. The GWTHandler from the GWT-SL will take care of your rpc call mapping. However, you will have a problem with your existing domain objects structure. You will either have to put them in GWT's 'client' package, or mirror your existing domain objects to enable them to be compiled to javascript. I have been looking for a stable non-invasive framework for doing this, but have yet to find one. Gilead looks promising, but you will have to extend its classes on your domain.
I have posted a view month ago my simple project (3 classes) how to integrate GWT with existing Spring MVC application. Simple sample also provided.
Try it, it is clear and simple: http://code.google.com/p/gspring.
You won't lose hosted mode. I don't know if you're using the internal server for that - I use -noserver so I can't help you there.
Other than that, I guess the documentation is quite clear. Have you hit any specific problems?

Resources