Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:55:40+00:00 2026-06-12T08:55:40+00:00

When creating a grails service many tutorials show something like: grails create-service myproject.DoStuff but

  • 0

When creating a grails service many tutorials show something like: grails create-service myproject.DoStuff but it would seem that grails create-service myproject.doStuff works just as well, and they both make a service called “DoStuffService” Using all upper case seems to work fine, but there seem to be lots of places that show it with a lower case first letter. I submit this example of lower case (the first code snip and def authorService about halfway down the page): http://grails.org/doc/2.1.0/guide/services.html

Which way is preferred? Why? If you create the service with lower case in the grails command do you need to inject it with lower case def doStuff or should def DoStuff work either way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:55:41+00:00Added an answer on June 12, 2026 at 8:55 am

    Both work, but I think it’s more common to lowercase the first name since conceptually you’re creating a “person service” with grails create-service person. But the convention in Java and Groovy is to upper-case class names, and in Grails to suffix service class names with “Service”, so this results in a class name of PersonService.

    The bean name is separate from all this though. The convention for Spring bean names is to lowercase the first letter like variables, so Grails auto-registers PersonService as the personService bean, so you should use def personService.

    The reason def personService works is that the Groovy compiler converts non-scoped fields like this to a private field and a public getter and setter method. If the getter or setter method already exists it won’t replace yours though. Grails configures its beans to use autowiring by name, so Spring sees the setPersonService method and calls it to set its value to the personService bean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using Grails, when creating the WAR archive, I would like to apply a
I am new to Grails. I have noticed that most tutorials show queries being
I'm creating a service class in grails that generates a JSON structure and uses
I am creating a Grails application that has read-only access to a web service
I am creating a Grails plugin and I would like for it to add
The standard way of creating URLs in grails is: <a href=${createLink(controller:'news', action: 'show', params:
I'm creating a REST service in Grails to accept data from a python script.
OK, I am creating a grails project, but I have php legacy code. Rather
I'm creating a Mavenised Grails project but am having trouble running the maven install
I am creating a new Grails project that uses some Java code to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.