Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating first Micronaut sample with maven dependencies #630

Closed
ghost opened this issue Sep 26, 2018 · 2 comments
Closed

Creating first Micronaut sample with maven dependencies #630

ghost opened this issue Sep 26, 2018 · 2 comments
Labels
closed: cannot reproduce The issue cannot be reproduced

Comments

@ghost
Copy link

ghost commented Sep 26, 2018

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.

Expected Behaviour

What I expected was the creation of a random port localhost which I would be able to invoke with, for example, postman's application.

Actual Behaviour

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"
.

Environment Information

  • Operating System: Microsoft Windows 10 Enterprise (v. 10.0.16299)
  • Micronaut Version: 1.0-SNAPSHOT
  • JDK Version: started with 10 but currently 1.8.0_181 (downgraded to check if would solve the issue)
  • IDE: Intellij Idea (with Annotation Processing enabled)

Code


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>
@jameskleeh
Copy link
Contributor

@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 jameskleeh added closed: notabug The issue is not a bug closed: cannot reproduce The issue cannot be reproduced and removed closed: notabug The issue is not a bug labels Sep 26, 2018
@ghost
Copy link
Author

ghost commented Sep 27, 2018

@jameskleeh Thanks for helping. It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: cannot reproduce The issue cannot be reproduced
Projects
None yet
Development

No branches or pull requests

1 participant