Getting a source error building Groovy project with Maven

前端 未结 2 1471
无人及你
无人及你 2021-01-23 15:35

I am trying to build my first groovy project with maven but I am getting the following error from maven.. its somettype of source error but Idont understand why I am getting it.

相关标签:
2条回答
  • 2021-01-23 16:04

    Your 1st clue is the error: No such property: project for class: org.jsmith.Example Apologies for restating your error as your answer but let me explain. It's saying that somewhere in your source you have a reference to a variable project. (possible in source you haven't posted or possibly in the source before you inadvertnly changed it and before you posted??)

    I imagine you probably had a typo in the package name or some extra test code after your class definition? For Eg. something like this could generate such an error:

    package org.smith
    
    /**
     * Example Groovy class.
     */
    class Example
    {
        def show() {
            println 'Hello World'
        }
    }
    println project.path
    

    Again, you should post both the updated code at the time of the error and the exact error matching the code. It's hard to determine based on what you have above where your problems lie.

    0 讨论(0)
  • 2021-01-23 16:06

    You will have to define project and bind to mavenProject if you are using script rather than inline.

    def project = ${project}; // this will bind to the Maven Project property.
    

    likewise

    def session = ${session} //will bind to MavenSession
    

    Source - Look for custom properties

    0 讨论(0)
提交回复
热议问题