How can I set "grails.gorm.default.mapping" in SpringBoot with GORM, and no Grails - grails-orm

I'm using GORM with SpringBoot, not in Grails.
How can I set "grails.gorm.default.mapping" and "grails.gorm.default.constraints" since SpringBoot only support properties in application.yml.
Thx!

Related

H2-console in r2dbc-h2 driver

I am using R2DBC-H2 driver, and my UR.L is spring.r2dbc.url=r2dbc:h2:mem:///customer
Using this configuration, SpringBoot starts fine, however, I can not access the h2-console.
Does anybody know why, and how I can fix it?
If I understand the source code of H2ConsoleAutoConfiguration correctly, the h2 console auto configuration from spring boot does not work in a reactive environment.
...
#ConditionalOnWebApplication(type = Type.SERVLET)
...
public class H2ConsoleAutoConfiguration {
You can confirm this by yourself by changing the type of your web application to SERVLET (for example, by adding spring-boot-starter-web as a dependency) which will activate the route to the h2 console (if enabled in the application properties). The h2-console route endpoint will start working again.
As the whole code seems very servlet-specific, I don't know how to properly fix this problem.
H2 Console depends on traditional Jdbc drivers, not compatible with Spring WebFlux stack.
If you are developing a WebFlux application, you can use H2 as a standalone database, ane use H2 Console freely.
Following the official Getting Started guide to start H2 Database and H2 Console.
Set your spring.r2dbc.url to the database url you are running in the first step.
NOTE: Do not use a Memory DB here.

How can I configure JAX-RS endpoints programmaticaly?

I'm trying to get rid of XML in my project.
I already tried to add this:
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CustomerService.class);
sf.setAddress("http://localhost:9000/");
sf.create();
to my Activator class, but my bundle wont start with this.
So, how usually people configuring endpoints?
(Sorry, no code, just some high level insights from my experience/projects)
I use jersey and its integration into the OSGi environment. I.e. org.glassfish.jersey.servlet.ServletContainer to which I register all jax-rs resources. This way, I can use whatever HTTP server implementation is available (for example, jetty) and configure it via the OSGi system environment properties.
For simplicity, I re-register annotated OSGi (declarative) services as singleton resources/endpoints into that ServletContainer.
Maybe, CXF has also a similar approach.

Webapp start and stop listener using jax-rs

I am using jax-rs for restful service. And I am trying to find out how I can use a contextlistener for webapp ? I am specifically using jax-rs 2.0 . Any suggestions on how to go about it , would be helpful. Thank you.
I'm not sure what linkage problem you have with servlet.jar. It should actually be in your classpath already, since JAX-RS uses it, too.
Also, if you use a framework such as Hibernate (or another JPA implementation for your MySQL database access), you may want to rely on the events that they trigger after insert/update/delete operations: see https://docs.jboss.org/hibernate/orm/4.0/manual/en-US/html/events.html for example.
Just my 2c.

How does Jackson get configured for Jersey in Spring Boot (SPI scanning seems to be disabled)

I'm using Spring Boot with Jersey 2. The only media provider is org.glassfish.jersey.media:jersey-media-json-jackson (checked the runtime classpath) so I guess I'm using it for JSON serialization. However, I don't configure it explicitly, but I noticed in JerseyAutoConfiguration#addInitParameters that scanning for SPIs is explicitly disabled with the following line:
registration.addInitParameter(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
The Jackson feature is defined in jersey-media-json-jackson.jar/!META-INF/services/..., but scanning it is disabled.
How does Jackson get configured for Jersey in Spring Boot?
According to the docs, Jackson gets automatically configured in Spring Boot (it just need to find Jackson lib in your classpath).
There are a lot of ways to configuring Jackson as you can see here in the docs.
If you want to see in details the configuration of Jackson in Spring Boot, take a look at JacksonAutoConfiguration class.

Adding custom operations to Admin console in jboss 7.1.1

I want to expose custom operations using jboss console. Like in jboss 4.2, we were using xmbeans to create our own interface & then invoke operations.
I found sample (https://docs.jboss.org/author/display/AS7/Example+subsystem) related to creating custom subsystem but that can be accessed using CLI only.However If its possible to expose the same set of operations and attributes in the web (admin) console?
If not, is there any plan for it?
Thanks for your help.
Best Regards,
Divya Garg