The following makes up "Assignment 0". It is intended to get you started developing right away, communicating questions/answers, and turning something in with some of the basics.

As with most assignments, a set of starter projects is available in assignment-starter/autorentals-starter. It is expected that you can implement the complete assignment on your own. However, the Maven poms and the portions unrelated to the assignment focus are commonly provided for reference to keep the focus on each assignment part. Your submission should not be a direct edit/hand-in of the starters. Your submission should — at a minimum:

  • be in a separate source tree — not within the class examples

  • have a local parent pom.xml that extends either spring-boot-starter-parent or ejava-build-parent

  • use your own Maven groupIds

    • change the "starter" portion of the provided groupId to a name unique to you

      Change: <groupId>info.ejava-student.starter.assignments.projectName</groupId>
      To:     <groupId>info.ejava-student.[your-value].assignments.projectName</groupId>
  • use your own Maven descriptive name

    • change the "Starter" portion of the provided name to a name unique to you

      Change: <name>Starter::Assignments::ProjectName</name>
      To:     <name>[Your Value]::Assignments::ProjectName</name>
  • use your own Java package names

    • change the "starter" portion of the provided package name to a name unique to you

      Change: package info.ejava_student.starter.assignment0.app.autorentals;
      To:     package info.ejava_student.[your_value].assignment0.app.autorentals;

The following diagram depicts the 3 modules (parent, javaapp, and bootapp) you will turn in. You will inherit or depend on external artifacts that will be supplied via Maven.

assignment0 autorentals app modules
Figure 1. Assignment Tree

1. Part A: Build Pure Java Application JAR

1.1. Purpose

In this portion of the assignment, you will demonstrate your knowledge of building a module containing a pure Java application. You will:

  1. create source code for an executable Java class

  2. add that Java class to a Maven module

  3. build the module using a Maven pom.xml

  4. execute the application using a classpath

  5. configure the application as an executable JAR

  6. execute an application packaged as an executable JAR

1.2. Overview

In this portion of the assignment you are going to implement a JAR with a Java main class and execute it.

assignment0a autorentals build javamain
Figure 2. Pure Java Main Application
In this part of the assignment, the name of the main class is shown specialized to "AutoRentals" since it contains (or directly calls) code having specifically to do with "AutoRentals".

1.3. Requirements

  1. Create a Maven project that will host a Java program

  2. Supply a single Java class with a main() method that will print a single "AutoRental has started" message to stdout

  3. Compile the Java class

  4. Archive the Java class into a JAR

  5. Execute the Java class using the JAR as a classpath

  6. Register the Java class as the Main-Class in the META-INF/MANIFEST.MF file of the JAR

  7. Execute the JAR to launch the Java class

  8. Turn in a source tree with a complete Maven module that will build and execute a demonstration of the pure Java main application.

1.4. Grading

Your solution will be evaluated on:

  1. create source code for an executable Java class

    1. whether the Java class includes a non-root Java package

    2. the assignment of a unique Java package for your work

    3. whether you have successfully provided a main method that prints a startup message

  2. add that Java class to a Maven module

    1. the assignment of a unique groupId relative to your work

    2. whether the module follows standard, basic Maven src/main directory structure

  3. build the module using a Maven pom.xml

    1. whether the module builds from the command line

  4. execute the application using a classpath

    1. if the Java main class executes using a java -cp approach

    2. if the demonstration of execution is performed as part of the Maven build

  5. execute an application packaged as an executable JAR

    1. if the java main class executes using a java -jar approach

    2. if the demonstration of execution is performed as part of the Maven build

1.5. Additional Details

  1. The root maven pom can extend either spring-boot-starter-parent or ejava-build-parent. Add <relativeParent/> tag to parent reference to indicate an orphan project if doing so.

  2. When inheriting or depending on ejava class modules, include a JHU repository reference in your root pom.xml.

    <repositories>
        <repository>
            <id>ejava-nexus-snapshots</id>
            <url>https://pika.jhuep.com/nexus/repository/ejava-snapshots</url>
        </repository>
    </repositories>
  3. The maven build shall automate to demonstration of the two execution styles. You can use the maven-antrun-plugin or any other Maven plugin to implement this.

  4. A quick start project is available in assignment-starter/autorentals-starter/assignment0-autorentals-javaapp Modify Maven groupId and Java package if used.

2. Part B: Build Spring Boot Executable JAR

2.1. Purpose

In this portion of the assignment you will demonstrate your knowledge of building a simple Spring Boot Application. You will:

  1. construct a basic Spring Boot application

  2. define a simple Spring component and inject that into the Spring Boot application

  3. build and execute an executable Spring Boot JAR

2.2. Overview

In this portion of the assignment, you are going to implement a Spring Boot executable JAR with a Spring Boot application and execute it.

assignment0b autorentals app bootapp
Figure 3. Spring Boot Application
In this part of the assignment, the name of the main class can be generalized to "RentalApp" since nothing about that class specifically has or calls anything to do with "AutoRentals". All details of the specialization are within the "AutoRentalCommand" component.

2.3. Requirements

  1. Create a Maven project to host a Spring Boot Application

  2. Supply a single Java class with a main() method that bootstraps the Spring Boot Application

  3. Supply a @Component that will be loaded and invoked when the application starts

    1. have that @Component print a single "AutoRental has started" message to stdout

  4. Compile the Java class

  5. Archive the Java class

  6. Convert the JAR into an executable Spring Boot Application JAR

  7. Execute the JAR and Spring Boot Application

  8. Turn in a source tree with a complete Maven module that will build and execute a demonstration of the Spring Boot application

2.4. Grading

Your solution will be evaluated on:

  1. extend the standard Maven jar module packaging type to include core Spring Boot dependencies

    1. whether you have added a dependency on spring-boot-starter (directly or indirectly) to bring in required dependencies

  2. construct a basic Spring Boot application

    1. whether you have defined a proper @SpringBootApplication

  3. define a simple Spring component and inject that into the Spring Boot application

    1. whether you have successfully injected a @Component that prints a startup message

  4. build and execute an executable Spring Boot JAR

    1. whether you have configured the Spring Boot plugin to build an executable JAR

    2. if the demonstration of execution is performed as part of the Maven build

2.5. Additional Details

  1. The root maven pom can extend either spring-boot-starter-parent or ejava-build-parent. Add <relativeParent/> tag to parent reference to indicate an orphan project if doing so.

  2. When inheriting or depending on ejava class modules, include a JHU repository reference in your root pom.xml.

    <repositories>
        <repository>
            <id>ejava-nexus-snaphots</id>
            <url>https://pika.jhuep.com/nexus/repository/ejava-snapshots</url>
        </repository>
    </repositories>
  3. The maven build shall automate to demonstration of the application using the spring-boot-maven-plugin. There is no need for the maven-antrun-plugin in this portion of the assignment.

  4. A quick start project is available in assignment-starter/autorentals-starter/assignment0-autorentals-bootapp. Modify Maven groupId and Java package if used.