§Creating a new Maven Eclipse project with the Lagom archetype
The Lagom Maven archetype allows you to quickly create a project for development. Follow these steps to:
§Check prerequisites
Before attempting to create a Lagom Maven project in Eclipse, ensure that Eclipse is configured with the following:
- An m2eclipse plugin compatible with Maven 3.3 or higher.
- A JDK 1.8 or higher.
§Create an Eclipse project
The screen shots on this page reflect Eclipse Neon (4.6.2) with M2E (Maven Integration for Eclipse) version 1.7.0. If you are using different versions, screens might differ, but the procedures should be the same.
In Eclipse, follow these steps to create a project using the Lagom Maven archetype:
- From the File menu, select New > Project.
The New Project screen opens. - Expand Maven, select Maven Project, and click Next.
The New Maven project wizard opens. - Leave the default, Use default Workspace location box selected and click Next.
The Select an archetype page opens. - If the Lagom archetype appears in the list, select it. If not, click Add Archetype and supply the following values:
- Archetype Group Id: com.lightbend.lagom
- Archetype Artifact Id: maven-archetype-lagom-java
- Version: The Lagom version number. Be sure to use the current stable release.
- Repository URL: Leave blank
-
Click OK.
The next page of the wizard opens, providing fields to identify the project and displaying thehello
andstream
properties from the archetype. -
To identify your project, enter the following:
- Group Id - Usually a reversed domain name, such as
com.example.hello
. - Artifact Id - Maven also uses this value as the name for the top-level project folder. You might want to use a value such as
my-first-system
. - Version - A version number for your project.
- Package - By default, the same as the
groupId
.
- Group Id - Usually a reversed domain name, such as
-
Click Finish and the projects created by the archetype display in the Package Explorer.
-
Run the project:
- Right-click the parent project folder.
Eclipse puts all of the Maven project folders at the same level, so be sure to select the correct one. For example, if you usedmy-first-system
as the Maven artifact ID, right-clickmy-first-system
. - Select Run as … > Maven Build.
- In the Goals field, enter
lagom:runAll
. - Select the JRE tab and make sure it is pointing at a JRE associated with a JDK.
- Click Run.
- Right-click the parent project folder.
The console should report that the services started. Verify that the services are indeed up and running by invoking the hello
service endpoint from any HTTP client, such as a browser:
http://localhost:9000/api/hello/World
The request returns the message Hello, World!
.