25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1 ■ Your First <strong>Spring</strong> Application<br />

After executing the above command, you should see something like the following output:<br />

spring run app.groovy<br />

Resolving dependencies..<br />

:: <strong>Spring</strong> Boot :: (v1.0.2.RELEASE)<br />

INFO 84872 --- [main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080<br />

INFO 84872 --- [main] o.apache.catalina.core.StandardService : Starting service Tomcat<br />

INFO 84872 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache<br />

Tomcat/7.0.52<br />

INFO 84872 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing <strong>Spring</strong><br />

embedded WebApplicationContext<br />

INFO 84872 --- [ost-startStop-1] o.s.web.context.ContextLoader<br />

: Root<br />

WebApplicationContext: initialization completed in 2030 ms<br />

INFO 84872 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http<br />

INFO 84872 --- [main] c.a.isf.spring.HelloWorldController : Started HelloWorldController in<br />

7.086 seconds (JVM running for 7.599)<br />

> Building 80% > :ch01:run<br />

Now you can go to any web browser and type in the URL http://localhost:8080, and you should see the same<br />

as Figure 1-3. The <strong>Spring</strong> Boot will know what to do when it’s running the app.groovy file. It will create a web context<br />

and response to any request based on the annotations provided.<br />

Summary<br />

In this chapter, you saw how to create a simple <strong>Spring</strong> “Hello World” application and run it. You also learned how<br />

<strong>Spring</strong> uses dependency injection to create all the dependencies and collaboration between classes. Thanks to the<br />

small example, you saw that it doesn’t matter what implementation you create, as long as you follow the interface,<br />

<strong>Spring</strong> will inject its implementation and have it ready when you need it.<br />

You got a small sneak peek of the <strong>Spring</strong> Boot, a new project by the <strong>Spring</strong> Team that will be covered in the<br />

following chapters. You also saw how <strong>Spring</strong> plays well with the Groovy programming language.<br />

The following chapters will cover more detail of the <strong>Spring</strong> <strong>Framework</strong>, its features, and its Extensions. You’ll<br />

learn how they work together and how they can be used in your daily development.<br />

12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!