Srping Boot In action: different than Roo?

paul nisset

Ranch Hand

Posts: 263

posted 1 year ago

Hi Craig,

How does Spring Boot differ from Spring Roo ?

Thank you,
Paul

Aaron Brooks

Greenhorn

Posts: 2

posted 1 year ago

Hi Craig,

I've been away from Java programming for a while since I moved into people / team management, and I've been thinking about learning Spring and writing web services to get back into coding. Spring Boot seems like a good way to go. I know a little bit about Spring from ~5 years ago but am now way out of date.

Would "Spring Boot in Action" be a reasonable place to pick up / start over from, or would you recommend a different book first before diving into this one?

Thanks!

-Aaron

Craig Walls

author
Ranch Hand

Posts: 363

8

posted 1 year ago

paul nisset wrote:How does Spring Boot differ from Spring Roo ?

I briefly compared them in a separate thread, but here's another take on it...

Spring Roo made it easy to get started with Spring development by enabling you to specify features you want to add to your project and having it generate code for those pieces. For instance, you could ask for a new model object and it would generate a model class for you; ask for a controller and you get a basic controller; ask for scaffolding for a model and you get scaffolding. In most/all cases, you get a Java class that you can edit alongside an AspectJ inter-type declaration (ITD...eg, an introduction) that you're supposed to check into source control, but not touch. For scaffolding purposes, Roo would also generate (and to some degree maintain) JSPX files for your views. You can edit the JSPX files, but care has to be taken to ensure you don't edit something that Roo will regenerate for you.

The AspectJ ITDs made a lot of people uncomfortable, either because fear of AspectJ or because you can't edit them. And the "Real Object Oriented" nature of Spring Roo (which is where Roo got its name...not from kangaroos) wasn't welcome by many developers who demanded that Roo bend to fit more common patterns.

In short, Spring Roo employs code generation to promote a very opinionated programming model...and it's not even an opinion that many developers are comfortable with.

In contrast, Spring Boot, while somewhat opinionated, doesn't enforce any opinions on the patterns you use to develop your app. Its opinions are focused primarily on how to configure the components your app uses--You're welcome to do whatever you want with your application code. And...those opinions are easily overridden by simply writing explicit configuration; auto-configuration will step back if it sees that you've already configured something it was going to configure. And there's no code generation of any kind. All of the code you check into source code is code you write and you're welcome to edit it however you see fit. And although you're welcome to use AspectJ if you want, Spring Boot doesn't require it.

Aaron Brooks wrote:Would "Spring Boot in Action" be a reasonable place to pick up / start over from, or would you recommend a different book first before diving into this one?

Indeed, Spring Boot is a great way to dive into Spring. It's entirely possible to write a complete (albeit extremely simple) Spring app using Spring Boot in less than a minute and fewer than 60 characters of code. It'd be impossible to achieve that kind of "getting started" story in Spring without Spring Boot. You can build on that experience to build more feature-filled applications, taking full advantage of Spring Boot to get stuff done quickly.

That's more or less the flow of the first couple of chapters of "Spring Boot in Action", so yes...I do think it'd be a great place to get started from. At some point you'll likely need to know more about how to explicitly configure Spring (because there are some things that Spring Boot can't do on its own and some other things you may want to override with explicit configuration). Because the focus is on Spring Boot, "Spring Boot in Action" doesn't go in depth on explicit configuration, even though it does show a few examples of how to do that. For a more in-depth coverage of how to do explicit configuration with Spring, I'd refer you to "Spring in Action, 4th Edition".

But since you asked about how to get started, then I certainly suggest "Spring Boot in Action". Once you've mastered that, you can pick up "Spring in Action" to figure out how to take your learning further.

paul nisset

Ranch Hand

Posts: 263

posted 1 year ago

Thanks for clarifying Spring Roo versus Spring Boot .
Sounds like Spring Boot has the same ease of use but is more flexible.

60 characters for an app is pretty impressive .

I'm a little disappointed 'Roo' isn't short for 'Kangaroo'.

-Paul

Craig Walls

author
Ranch Hand

Posts: 363

8

posted 1 year ago

paul nisset wrote:60 characters for an app is pretty impressive .

Since it was mentioned:

That's every single character of code required. The only prerequisite is that you have installed the Spring Boot CLI and run it with "spring run H.groovy". It will handle any HTTP request to localhost:8080 with "Hi!".

Note that the CLI is an optional (albeit, not a toy) approach to working with Spring Boot. You certainly can still use Java built with Maven or Gradle to produce executable JARs or WAR files.

That's every single character of code required. The only prerequisite is that you have installed the Spring Boot CLI and run it with "spring run H.groovy". It will handle any HTTP request to localhost:8080 with "Hi!".

Note that the CLI is an optional (albeit, not a toy) approach to working with Spring Boot. You certainly can still use Java built with Maven or Gradle to produce executable JARs or WAR files.

That is cool ... or at least Groovy.

Enrique Ruiz

Greenhorn

Posts: 1

posted 8 months ago

Strictly you cannot compare Spring Boot with Spring Roo:

* Spring Roo is a development tool, so you use it at development time.
* Spring Boot works in runtime.