TomCat port is occupied when SpringBoot runs for the second time

Error display on second startup

The reason for the error is different from the traditional Spring family framework. The main function of SpringBoot is the entrance of the whole program. SpringBoot even integrates Tomcat as a plug-in, so it is different from the previous SSM architecture. Just click to run the main function, and then go to the browser to view it, you can see that it is exciting "Hello World!".

But here comes the problem. At this time, the program is still running. When the main is started for the second time, TomCat is integrated again. Because it has been integrated for the first time, at this time, the error seen above is reported, and the TomCat port is occupied.

How to do it? Stop the program, then start it again!

It's the second-to-last little red square. Click Finish. Then start. That's it.

If you think it is so troublesome, then click the inverted triangle of the little red square at the back, and then select demo-DemoApplication. You can restart the program. demo is your project name. The next time you restart, the default is the demo-DemoApplication selected last time, so just click this button.

Then the problem comes again. During the project development process, the code must be constantly modified. If you have to restart the program every time you change the code, is it very troublesome? Is there a way to solve?

some. Log in to http://www.mvnrepository.com and search for Springloaded

click this

After copying the configuration to pom.xml, don't worry, you still need to rely on one. Search for spring-boot-devtools at http://www.mvnrepository.com and add it to pom.xml.

The picture below is the configuration I added.

After configuration, there will be one more [devtools] behind the project


Then restart the program.

Note: No need to move all over. If your <version> is marked yellow, you can delete the <version> line.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324504391&siteId=291194637