What's the difference in Grails between run-app and IntelliJ's run.Aplication

2

I'm working 1 year with Grails and IntelliJ Community 14, and I've been noticing some different behaviors between running the project through the command line and using the IDEA Run 'Aplication.main ()'.

I put this doubt to try to understand at once what the difference is. I will try to exemplify with a situation that I came across lately.

Think of two entities. A "Service" and another "Status", as below:

class Servico {

   static hasOne = [status: Status]

   static constraints = {
       status nullable: true
   }
}

class Status {

   String nome
   static hasMany = [servicos: Servico]

   static constraints = {
      nome nullable: false, unique: true
   }
}

The project works normally by running IDEA, but when using the run-app from the command line, the following error occurs when trying to save a "Service":

object references an unsaved transient instance - save the transient instance before flushing: project.Status

What does not make much sense since the Status already exists on the base before the Service.

After that, when trying to run the project again in IDEA, another error occurs on the face:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor' defined in project.Application: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is java.lang.NoClassDefFoundError: grails / gorm / Entity

To be able to run again, I need to use a "grails clean". After this command (or delete the build folder) the project works again correctly.

Apparently the IDEA is generating a different build folder from the run-app-generated folder.

Does anyone have any light on this?

    
asked by anonymous 09.05.2016 / 08:24

0 answers