Micronaut controller error Page Not Found
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 |
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 |
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 '18 at 6:23
saw303
3,43212955
3,43212955
asked Nov 19 '18 at 18:06
Khwaja SanjariKhwaja Sanjari
9411
9411
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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-groovydependency.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 at 19:24
1
If you checkout the project I linked and run./gradlew run(orgradlew runif you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 '18 at 19:25
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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-groovydependency.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 at 19:24
1
If you checkout the project I linked and run./gradlew run(orgradlew runif you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 '18 at 19:25
|
show 3 more comments
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-groovydependency.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 at 19:24
1
If you checkout the project I linked and run./gradlew run(orgradlew runif you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 '18 at 19:25
|
show 3 more comments
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 '18 at 18:19
Jeff Scott BrownJeff Scott Brown
14.9k11731
14.9k11731
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-groovydependency.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 at 19:24
1
If you checkout the project I linked and run./gradlew run(orgradlew runif you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 '18 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-groovydependency.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 at 19:24
1
If you checkout the project I linked and run./gradlew run(orgradlew runif you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
– Jeff Scott Brown
Nov 19 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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
