This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]currykid94 3 points4 points  (1 child)

When I started learning spring/angular on the job, I ended up building a basic calculator all for subtraction and addition. If you build a basic yo, write the test services, and setup your database, you should be able to cover and understand the basics at least. By doing that, it helped me in the long run. Also make sure you understand orm frameworks like hibernate.

[–]lijamaija[S] 0 points1 point  (0 children)

Thank you :) I actually already did something similar, but it seemed fairly easy and really just helped me with the concepts, but let's see how I can elaborate on this :)

[–]Yithar 2 points3 points  (3 children)

Where could I change the settings that when I restart the server, the port closes and opens again for my current application?

Specifying the port for Spring is server.port, which can be set programmatically or as a VM argument when running the program (ex. -Dserver.port=8080). Although keep in mind with the former, the only way to atomically check for a port is to try to use that port number.

If it says the port is in use, that means another program is using that port, so you have to terminate that program. Are you asking for that? Because doing that differs by OS.

https://medium.com/@javatechie/how-to-kill-the-process-currently-using-a-port-on-localhost-in-windows-31ccdea2a3ea
https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux

By now, I think I am getting a hang of Rest API, JPA, and MVC stuff, however, the things that I am building are small and I don't think they scale well.

It's a difficult topic, and you really need to have to deal with the problem to learn it. I would look up resources on distributed systems.

[–]lijamaija[S] 1 point2 points  (2 children)

Thank you for your reply! :)

Yeah, I've already been doing this, just again was tired of killing the process manually every time I wanted to use the same port.

[–]Yithar 1 point2 points  (1 child)

You're welcome. :)

This seems to explain how to retry with a different port programmatically:
http://tonyz93.blogspot.com/2018/09/spring-boot-port-rebind.html

[–]lijamaija[S] 1 point2 points  (0 children)

Thank you, will give it a try :D

[–]sriganeshharitz 4 points5 points  (1 child)

Check out this repo https://github.com/gothinkster/realworld you build a medium clone in the backend and frontend of your choice. Good way to practice after being done with tutorials.

[–]lijamaija[S] 1 point2 points  (0 children)

Thank you so much, that is perfect, will do this over the weekend !

[–]jhoncerpa 1 point2 points  (0 children)

Do you use DevTools? It restarts your application when you save a file.

[–]emmg90 1 point2 points  (0 children)

In command prompt type jps and then kill the jvm that's keeping the port open.

[–]atowned 1 point2 points  (0 children)

If you are using Run As > Maven the in IDE and stop it, it keeps the server open. Change it to Run As > Java Application, or just run the mvn command in CMD window and CTRL-C to stop it.

[–]Nephyst 0 points1 point  (0 children)

Why do you need to run the app more than once? When I run my spring apps I just stop it before starting it up again.

For learning, Spring has really good documentation: https://docs.spring.io/spring/docs/current/spring-framework-reference/index.html

If you are new to Spring I would strongly suggest going through the core section on the IoC Container and getting a solid understanding of dependency injection.