I have a grails web application with a domain model and a hibernate datasource persistence.
I would like to write now a command line tool in groovy to access also this domain model and the hibernate datasource.
Any ideas how I can do this?
regards
Vanigor
You can use Spring Boot as described in this article.
That example creates a small web UI, but Boot can be configured as a CLI app.
Related
I have created an angular application under grails. I would like to separate it now from grails and make it a gradle application (generation of the final files would be gradle job). However in the interim I would still like to use my taglibs How can I render gsp under gradle without grails loaded?
TIA
Pascal
There is GSP for Spring Boot a.k.a Standalone GSP available.
See examples: https://github.com/grails/grails-boot/tree/master/sample-apps/gsp
Example of a standalone Spring Boot groovy script: https://github.com/grails/grails-boot/blob/master/sample-apps/gsp/script/app.groovy (requires currently the provided run_app.sh script for launching)
It doesn't support all Grails taglibraries. Only sitemesh and render taglibs are supported of the Grails core taglibs.
However, you can reuse taglibraries if you annotate them with the grails.gsp.TagLib annotation and register them as beans in the application context that runs the Spring Boot application.
I am using the new grails 2.3.4 with Spring Security Core 2.0-RC2 plugin. I have generated the domain objects and got also a user via the Bootstrap.groovy into the db. However, I am wondering where to specify a custom login for my page?
Is it also possible to do the sign up process via the spring security plugin?
I appreciate your answer!
Create a gsp in the following pattern: grails-app/views/login/auth.gsp.
This way the default template is automatically replaced.
I have been handed a .WSDL file which I need to test within a Grails Framework.
Any suggestions how to go about this.
Take a look at the http://grails.org/plugin/cxf and http://grails.org/plugin/cxf-client plugins. They're easy to use and backed by Apache CXF - https://cxf.apache.org/
The client plugin has a wsdl2java script that will generate code that you can use in your Grails app.
You could start with documentation itself: http://grails.org/Calling+External+WebServices
First I'm new to grails as well website development.I started grails project and studying.
I'm clear about grails concepts like Domain class, controller, view, agile development like this.
While executing grails run-app command, at which point does grails start execution in the framework and run (like main() method in Java)?
Which is the first entry place domain or controller or view or main.gsp in my project from where it is coming from grails framework?
When server starts up, Bootstrap.groovy is executed.
For listening to each request you probably would need to define your own filter.
However the very beginning of every request is the org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.
When a request comes in, grails determines the controller and the action (based on the URL and any UrlMappings you've specified) and calls it. So from your application code's point of view, the starting point is one of your actions.
For example:
If a user requests http://abc.com/book/list, where abc.com is your site, the method def list() in your BookController.groovy is the starting point.
Internally, grails calls each closure in AppFilters.groovy (and other filters defined by you or the plugins you are using) if any before calling your controller's action. If you are developing a very simple app, those wouldn't matter.
Grails incorporates the powerful build system Gant, which is a Groovy wrapper around Apache Ant.
When you run the command : Grails [commad-name],
Grails searches in the following directories for Gant scripts to execute:
USER_HOME/.grails/scripts
PROJECT_HOME/src/main/scripts/
PROJECT_HOME/plugins/*/scripts
GRAILS_HOME/scripts
When you execute Grails run-app command, It will execute the file RunApp.groovy file from above mentioned paths. These are groovy files, once you look into files, you will understand the code inside that.
I have already create a Grails application. For some reasons I need to create another console application for someone to modify database data.
Is it possible to package Grails application as a JAR library, so that the console application can reuse those domain classes?
Or, I add/create some classes in Grails application and package it as a JAR and run as console application?
If no better answer, probably I will use the batch-launcher plugin to do that.
You can put the domain classes in a JAR and tell Grails that these are your domain classes by adding a Hibernate XML file (in grails-app/conf/hibernate) that refers to the classes in this JAR. You can use this JAR in any other Java/Groovy application, but obviously they'll only have the persistence methods (dynamic finders, save(), etc.) when used in a Grails app.