Micronaut controller error Page Not Found
up vote
0
down vote
favorite
I created a new micronaut app using
mn create-app example.micronaut.complete
After that I opened the project using intellij and added a new class as TestController to the project with code below:
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
TestController(){}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest(){
return "some string";
}
}
But I am getting
{"_links":{"self":{"href":"/","templated":false}},"message":"Page Not Found"}
whenever I try to access the /hello end point
My application.yml looks like this:
micronaut:
application:
name: complete
server:
port: 8080
micronaut
add a comment |
up vote
0
down vote
favorite
I created a new micronaut app using
mn create-app example.micronaut.complete
After that I opened the project using intellij and added a new class as TestController to the project with code below:
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
TestController(){}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest(){
return "some string";
}
}
But I am getting
{"_links":{"self":{"href":"/","templated":false}},"message":"Page Not Found"}
whenever I try to access the /hello end point
My application.yml looks like this:
micronaut:
application:
name: complete
server:
port: 8080
micronaut
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I created a new micronaut app using
mn create-app example.micronaut.complete
After that I opened the project using intellij and added a new class as TestController to the project with code below:
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
TestController(){}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest(){
return "some string";
}
}
But I am getting
{"_links":{"self":{"href":"/","templated":false}},"message":"Page Not Found"}
whenever I try to access the /hello end point
My application.yml looks like this:
micronaut:
application:
name: complete
server:
port: 8080
micronaut
I created a new micronaut app using
mn create-app example.micronaut.complete
After that I opened the project using intellij and added a new class as TestController to the project with code below:
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
TestController(){}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest(){
return "some string";
}
}
But I am getting
{"_links":{"self":{"href":"/","templated":false}},"message":"Page Not Found"}
whenever I try to access the /hello end point
My application.yml looks like this:
micronaut:
application:
name: complete
server:
port: 8080
micronaut
micronaut
edited Nov 28 at 6:23
saw303
3,40712955
3,40712955
asked Nov 19 at 18:06
Khwaja Sanjari
838
838
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
// this empty constructor is not
// needed, but isn't a problem...
TestController() {
}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest() {
return "some string";
}
}
The endpoint responds:
$ curl http://localhost:8080/hello
some string
One thing to look for is you may be missing the micronaut-inject-java
and/or micronaut-inject
dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.
Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need themicronaut-inject-groovy
dependency.
– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
If you checkout the project I linked and run./gradlew run
(orgradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 at 19:25
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
// this empty constructor is not
// needed, but isn't a problem...
TestController() {
}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest() {
return "some string";
}
}
The endpoint responds:
$ curl http://localhost:8080/hello
some string
One thing to look for is you may be missing the micronaut-inject-java
and/or micronaut-inject
dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.
Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need themicronaut-inject-groovy
dependency.
– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
If you checkout the project I linked and run./gradlew run
(orgradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 at 19:25
|
show 3 more comments
up vote
1
down vote
accepted
Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
// this empty constructor is not
// needed, but isn't a problem...
TestController() {
}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest() {
return "some string";
}
}
The endpoint responds:
$ curl http://localhost:8080/hello
some string
One thing to look for is you may be missing the micronaut-inject-java
and/or micronaut-inject
dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.
Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need themicronaut-inject-groovy
dependency.
– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
If you checkout the project I linked and run./gradlew run
(orgradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 at 19:25
|
show 3 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
// this empty constructor is not
// needed, but isn't a problem...
TestController() {
}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest() {
return "some string";
}
}
The endpoint responds:
$ curl http://localhost:8080/hello
some string
One thing to look for is you may be missing the micronaut-inject-java
and/or micronaut-inject
dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.
Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.
Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...
package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/hello")
public class TestController {
// this empty constructor is not
// needed, but isn't a problem...
TestController() {
}
@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest() {
return "some string";
}
}
The endpoint responds:
$ curl http://localhost:8080/hello
some string
One thing to look for is you may be missing the micronaut-inject-java
and/or micronaut-inject
dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.
Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.
answered Nov 19 at 18:19
Jeff Scott Brown
14.8k11731
14.8k11731
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need themicronaut-inject-groovy
dependency.
– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
If you checkout the project I linked and run./gradlew run
(orgradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 at 19:25
|
show 3 more comments
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need themicronaut-inject-groovy
dependency.
– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
If you checkout the project I linked and run./gradlew run
(orgradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 at 19:25
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the
micronaut-inject-groovy
dependency.– Jeff Scott Brown
Nov 19 at 18:23
It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the
micronaut-inject-groovy
dependency.– Jeff Scott Brown
Nov 19 at 18:23
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
– Khwaja Sanjari
Nov 19 at 19:09
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
"I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
– Jeff Scott Brown
Nov 19 at 19:21
1
1
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
– Jeff Scott Brown
Nov 19 at 19:24
1
1
If you checkout the project I linked and run
./gradlew run
(or gradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.– Jeff Scott Brown
Nov 19 at 19:25
If you checkout the project I linked and run
./gradlew run
(or gradlew run
if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.– Jeff Scott Brown
Nov 19 at 19:25
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380347%2fmicronaut-controller-error-page-not-found%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown