i am still a beginner with spring boot, and i have a bunch of questions.
First of all, do i have to download maven in my pc and add it to my pc path envirement to make spring boot work correctly ?
Secondly, Spring boot wasn't able to work, was doing a hello world app and there were lot of errors on the console one of them is "SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".. why that ? i looked for the error and followed some mvn command line steps "mvn dependency:purge-local-repository", and my app finally worked.. but do i have to run this command everytime i create a spring boot app ? isn't everything supposed to be alright since it's only a hello world app ? ..
Thank you
Yes, you need to have installed maven or gradle in order to run your application. And it needs to be reachable, so you have to configure your system variables accordingly.
You can find more details here.
As per the maven error, maven keeps all the artifacts you need to run your application in a shared folder with all versions, sometimes maven could have corrupted files or a mismatch in version so you need to purge the repository and download artifacts again.
You can find a more detailed answer here.
Even when you are coding a simple application, spring-boot bring up a lot of code for supporting operations you may require, such code is self configured and hidden.
Related
After installing the Java Extension Pack, Spring Boot Extension Pack, and Lombok, I created a basic Spring Boot project just to test out VSCode (I followed the Spring Boot initializer which works surprisingly well).
I attempted to run the application (barebones / skeleton project) and when clicking on the "Play" button and selecting "Run Java", the Run dialog hangs indefinitely.
I can run the project from the command line, using maven to compile it followed by java -jar; however, I want to be able to do everything in VSCode including running and debugging.
I clicked on "check details", but there isn't any information for me to go by and make an educated guess as to what is going on.
EDIT:
Just to be clear, I am running VSCode on FreeBSD (which is not Linux).
you can have a look on this extension whitch look like Boot Dashboard in Eclipse and it enable you to manage your application and have a control above it andu can run multiple projects using it in this Link.
Note: i think it need java 11 to work
Here is a description of how to use springboot. You can refer to it to see if there is a problem with any operation.
https://code.visualstudio.com/docs/java/java-spring-boot
I was wondering how can you deploy a Jar file that contains a self-contained app (grizzly) with Jersey framework to AWS Elestic Bean, I've been trying to deploying it by choosing the genereated jar file. But Beanstalk always throws an error. I haven't been able to make it work on AWS. I'm compiling the example that comes with the artifact jersey-quickstart-grlizzly. Any guide of how to do it will be more than welcome!
What i've done so far
Create an instance of AWS Beanstalk.
Set as platform JAVA.
Choose as source a JAR generated by maven build
Deploy.
Once it finishes, it says that the health has been changed to Degraded. That's all.
Update:
Looking for the error 502 I found a suggestion that says that I should run it by command prompt and see what happens. I have forgotten to add the main class attribute in POM. However, it's still showing the same message.
Perhaps, do you have any example of a working example with grizzly that I can deploy to AWS and use for getting started?
After some research I finaly found that the problem was the Port. Perhaps, someone else face this issue because the lack of experience with Java an those frameworks which is my case.
Build your jar as usual an then:
Go to beanstalk.
In the beanstalk intance where select the environment.
Click on the configuration section and edit "Software"
Add a property called SERVER_PORT with value 5000*.
This will redirect to the right port.
I have created a simple springboot application with inbuild tomcat which works fine when I am running it as JAVA Application in Eclipse. I tried to export this as a WAR file and tried to run it in Windows command line and also in UNIX box. I tried to execute it like below,
java -jar C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: An unexpected error occurred while trying to open file C:\Users\Iam\Documents\SpringHelloWorld.war
java -cp C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: Could not find or load main class main.java.com.controller.SpringBootWebApplication
I just export it as a WAR file, should i need to define anything before exporting it as WAR in Springboot ( note: i am not using maven or gradle )
Below is my project structure :
enter image description here
Probably it is possible to do this without Maven/Gradle, but I would never take this approach.
Even considering the best case, you will end up re-creating what others have created in the Spring Boot parento pom.xml or in his Gradle equivalent, so why you would waste a lot of time recreating what is already created by someone else? If you really want to know how the war is created, then take a look in Spring Boot parent pom, but you should limit your work to wrap what is ready for production in order to compose your solution.
Also consider that Maven and Gradle are constantly developed and updated, along everything belongs to their ecosystems. If you plan to replace them, then you should be prepared to mantain and develop alone your own build platform, which is a non-trivial effort.
Better include Maven or Gradle, you'll be more productive.
I have spent the weekend trying to run some simple Spring REST applications. Lots of examples on the net. However, whenever I got to running these, my application would always give me a 404 - Resource not found exception. To ensure I was doing everything right, I even restarted the applications from scratch a few times.
If I go to the project folder and run mvn tomcat7:run the project works as expected. However, when adding the project to my Tomcat7 server inside Eclipse and running it there, I always get a 404 error.
Any ideas on what is going wrong would be greatly appreciated.
I think the problem is src/main/java folder , you said you manually create it. so you did not add it to Source after create it?
Update
i just import the code to eclipse,and i modify the Web Module Path,and it worked. here is the snap:
and the test url
hope this is useful.
So I integrated MyBatis with Spring successfully(?) I think, because all my jUnit Test Methods are working correctly. I only received this error when Im trying to launch the web app locally on my tomcat server here is the stack trace:
Here's my web.xml
I can provide you with more of my codes if you want to. And yes I didn't use maven here.
UPDATE: Added a screenshot of my packaging.
UPDATE: Added library screenshot. Prolly thinking because of the version of spring?:
I think, after your descriptions the problem is, that Eclipse is not recognizing your libraries automatically (otherwise, they would have a small added icon on its main icon, which would look like the Libraries icon). The reason for this could be, that you have configured WEB-INF as source folder, which it shouldn't be (since you don't have any Java sources in it). So first i suggest to remove that configuration. Then Eclipse should pick your libraries automatically, when you deploy the application.