Skip to Main Content
Maven: The Definitive Guide
book

Maven: The Definitive Guide

by Sonatype Company
September 2008
Intermediate to advanced content levelIntermediate to advanced
470 pages
14h 22m
English
O'Reilly Media, Inc.
Content preview from Maven: The Definitive Guide

Simple Weather Source Code

The simple weather command-line application consists of the following five Java classes:

org.sonatype.mavenbook.weather.Main

The Main class contains a static main() function, and is the entry point for this system.

org.sonatype.mavenbook.weather.Weather

The Weather class is a straightforward Java bean that holds the location of our weather report and some key facts, such as the temperature and humidity.

org.sonatype.mavenbook.weather.YahooRetriever

The YahooRetriever class connects to Yahoo! Weather and returns an InputStream of the data from the feed.

org.sonatype.mavenbook.weather.YahooParser

The YahooParser class parses the XML from Yahoo! Weather, and returns a Weather object.

org.sonatype.mavenbook.weather.WeatherFormatter

The WeatherFormatter class takes a Weather object, creates a VelocityContext, and evaluates a Velocity template.

Although we won’t dwell on the code here, we will provide all the necessary code for you to get the example working. We assume that most readers have downloaded the examples that accompany this book, but we’re also mindful of those who may wish to follow the example in this chapter step-by-step. The sections that follow list classes in the simple-weather project. Each of these classes should be placed in the same package: org.sonatype.mavenbook.weather.

Let’s remove the App and the AppTest classes created by archetype:create and add our new package. In a Maven project, all of a project’s source code is stored in src/main/java. From ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Apache Maven Cookbook

Apache Maven Cookbook

Raghuram Bharathan
Mastering Apache Maven 3

Mastering Apache Maven 3

Prabath Siriwardena
Learning Apache Maven

Learning Apache Maven

Kevin Bowersox

Publisher Resources

ISBN: 9780596517335Supplemental ContentErrata Page