• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Problem with SpringBoot in Eclipse

 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error:The import org.springframework.boot.test cannot be
resolved
Error:SpringBootTest cannot be resolved to a
type.





Ska-rmavbild-2020-03-18-kl.-23.40.45.png
[Thumbnail for Ska-rmavbild-2020-03-18-kl.-23.40.45.png]
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also sorry put it in  wrong  forum, could someone change it to the right one
 
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see you have declared dependency for 'spring-boot-starter-test' artifact.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.4.RELEASE:repackage (repackage) on project springboot-registration-login: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.4.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.hellokoding.auth.WebApplication, com.hellokoding.auth.web.WebApplication] -> [Help 1]

I fixed it now. Got a new error but only when using maven clean install. I think it could be that a lot of my imports are not use like for example: Multiple markers at this line
- The import org.springframework.boot.web.servlet.support.SpringBootServletInitializer is never
used
- The import org.springframework.boot.builder.SpringApplicationBuilder is never used
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you fix this error ? and now you are encountering this one

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.4.RELEASE:repackage (repackage) on project springboot-registration-login: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.4.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.hellokoding.auth.WebApplication, com.hellokoding.auth.web.WebApplication] -> [Help 1]

?

The unused imports you are mentioning are just compiler warnings, not errors, and they should not cause maven compilation to fail (unless you are instructing maven to handle warnings as errors, which you are not, as far as I can see).
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I fixed it with this code:
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, from that new error, it seems like you have in your project two separate main() methods (in classes com.hellokoding.auth.WebApplication, com.hellokoding.auth.web.WebApplication) and maven just can't decide without you telling him which one he should use. You should provide configuration tag specifying class with main() method to use, eg:

 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe try this part for spring-boot-maven-plugin...

 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the help
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem Is the issue completely resolved, then ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes no error when I use maven clean install. Gonna figure out how to run it on the server now, thanks
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why does it show me no errors when compiling it and when I run the app it shows me:
Field userService in com.hellokoding.auth.web.UserController required a bean of type 'com.hellokoding.auth.service.UserService' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.hellokoding.auth.service.UserService' in your configuration.
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to tell Spring to create a bean of a class. You can tell him that by annotating UserService with '@Service' annotation.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like this? Still got the same error message

 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, like that, although, you need to annotate implementation class, not interface.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still the same error

 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still error in Controller not finding UserService bean ? Do you have '@SpringBootApplication' class annotation at a class containing main() method you're running ? Where is this class located ? I mean package.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It is located in hellokoding.auth.web I removed hellokoding.auth.web because it hade a file that was a duplicate of webapplication.
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, by default, Spring looks for bean defining classes in all subpackages of package, where you have '@SpringBootApplication'. Usually such class is placed to the root package, so you can move the 'WebApplication' class one folder up (to package 'com.hellokoding.auth'), that way package 'com.hellokoding.auth.service' containing UserService class will be a subpackage and therefore will be scanned by Spring, or you can define packages to scan by Spring using annotation '@ComponentScan(“com.hellokoding.auth.service”)'. Place this annotation on top/under '@SpringBootApplication' annotation.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now it caused this error in my pom:
/Users/marcou/another-spring-boot/target/classes/META-INF/MANIFEST.MF (No such file or
directory)
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

martin codey wrote:Now it caused this error in my pom:
/Users/marcou/another-spring-boot/target/classes/META-INF/MANIFEST.MF (No such file or
directory)



Did you try to rebuild/recompile the project ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is fixed but when i started the application and put localhost... in the browser I got this:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Mar 19 17:27:13 CET 2020
There was an unexpected error (type=Not Found, status=404).
/login.jsp
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was the rebuild/recompilation itself sufficient to resolve that issue or did you do something additional to resolve previous issue ?

If you don't have mapping for specific url you are trying to load, its normal. Also, just to be sure, spring boot fires up the application by default on port 8080, be sure to include that in the URL.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not do anything additional just as you said.

I know but in the browser when typing localhost:8080 it doesnt show login page as it show on this tutorial:
Tutorial
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you provide your UserController class here ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have respective .jps pages (welcome.jsp, ...) in right locations ? If so, then check if you have proper authorization access set in 'WebSecurityConfig' class.
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure. They look like this.

Ska-rmavbild-2020-03-20-kl.-11.11.56.png
[Thumbnail for Ska-rmavbild-2020-03-20-kl.-11.11.56.png]
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to be fine. I suspect that you may have wrong security configuration in 'WebSecurityConfig' class. You can post the code again here, but since you're following tutorial with full source code available, did you check your code against the code from tutorial ? If you just didn't forget to include some code ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pasted it in now and still the same.

 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you verify that your application server is up and running ? That you did not get any runtime exception when starting the application ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Used terminal and typed cd ~/another-spring-boot and then i typed mvn clean spring-boot:run and it said the application was running.
Then in browser(chrome) i typed http://localhost:8080
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to chase the real problem like this as we only have partial info about the state of your project. I tried to clone tutorial repository and tried to run the project you're trying to run, with docker-compose as proposed in tutorial, and here's my result when hitting 'http://localhost:8080/':

1.png
[Thumbnail for 1.png]
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you're trying to run it with maven, are you running MySQL server ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is my compose.yml. Yes I am running mysql
Ska-rmavbild-2020-03-20-kl.-23.13.37.png
[Thumbnail for Ska-rmavbild-2020-03-20-kl.-23.13.37.png]
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got this build failure when running docker-compose up:
[INFO] ------------------------------------------------------------------------
registration-login_1  | [INFO] BUILD FAILURE
registration-login_1  | [INFO] ------------------------------------------------------------------------
registration-login_1  | [INFO] Total time: 42.754 s
registration-login_1  | [INFO] Finished at: 2020-03-21T21:39:26Z
registration-login_1  | [INFO] ------------------------------------------------------------------------
registration-login_1  | [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.4.RELEASE:run (default-cli) on project springboot-registration-login: Application finished with exit code: 1 -> [Help 1]
registration-login_1  | [ERROR]
registration-login_1  | [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
registration-login_1  | [ERROR] Re-run Maven using the -X switch to enable full debug logging.
registration-login_1  | [ERROR]
registration-login_1  | [ERROR] For more information about the errors and possible solutions, please read the following articles:
registration-login_1  | [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
another-spring-boot_registration-login_1 exited with code 1
 
martin codey
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all of your help and time. It solved now.
 
Miroslav Lehotsky
Rancher
Posts: 103
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to see you managed to work it out. Care to share what was the problem ?
 
martin codey
Ranch Hand
Posts: 90
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cloned it and compared and the difference was that in the first project I hade a different version of the jar in the referenced library and different version in maven dependecies and pointing different in the pom file.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic