I followed this (http://guides.micronaut.io/creating-your-first-micronaut-app/guide/index.html) guide but instead of generate a Gradle project I created a new project with maven dependencies.
In that way I only have two classes: Application.java and HelloController.java.
My purpose was to simply run Application.java in Intellij's IDE.
What I expected was the creation of a random port localhost which I would be able to invoke with, for example, postman's application.
What really happens is that when I run the class the following message appears:
_"io.micronaut.runtime.Micronaut start
INFO: No embedded container found. Running as CLI application"_.
HelloController.java
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.Produces;
@Controller("/hello")
public class HelloController {
@Get("/")
@Produces(MediaType.TEXT_PLAIN)
public String index() {
return "Hello World";
}
}
Application.java
package example.micronaut;
import io.micronaut.runtime.Micronaut;
public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class);
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-
4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microservice</groupId>
<artifactId>example-micronaut</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>example.micronaut.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JAVA 9+ and LOG dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<!-- Project dependencies -->
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>runtime</artifactId>
<version>1.0.0.M4</version>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>http-client</artifactId>
<version>1.0.0.M4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@mOo7King On a Windows 10 machine, I took the following steps using Micronaut 1.0.0.M4 (git bash shell):
mn create-app test --build maven
cd test
./mvnw compile
./mvnw exec:exec
The application started successfully.
The pom.xml file you have there will definitely not work as there is more configuration that is required.
@jameskleeh Thanks for helping. It worked for me.
Most helpful comment
@mOo7King On a Windows 10 machine, I took the following steps using Micronaut 1.0.0.M4 (git bash shell):
mn create-app test --build mavencd test./mvnw compile./mvnw exec:execThe application started successfully.
The
pom.xmlfile you have there will definitely not work as there is more configuration that is required.