JavaEE simple example - some errors that may occur when using Tomcat

a brief introdction:

When we used Tomcat before, it often appeared that the project could not start normally due to some errors during startup. Let's take a look at the possible causes of some common errors and how to solve them after the errors occurred.

严重: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Address already in use: JVM_Bind <null>:80

This error is very obvious. The key words are: Address already in use: This sentence means that the port we use to start the service is occupied. This error often appears when we are debugging. We repeatedly start the Tomcat server, causing our previous server to For some reason, it was not shut down properly, which caused the port to be occupied when we started subsequent servers, so we must ensure that the same process is started as much as possible.

When this error occurs, either stop the previous process. Killing the process is easier on Linux, but it is more troublesome on Windows. If you don't consider other things and just want the service to start, then you can ignore the previous service. Simply modify the port number of the current service:

Modify the Tomcat port number here, then refresh the pom file, and then start the Tomcat server again:

 The address here will also change. Click the address here this time, and then you can start Tomcat normally. As for the previous service, it will probably disappear after we restart the computer.

 

 Usually the @Test annotation is missing and cannot be run.

This error is usually caused by miswriting the value of the namespace in the SQL mapping file and the value of the attribute in Mappers in the MyBatis core configuration file. Check whether the two values ​​​​are the same.

 When using <foreach> to traverse a Map, the value traversed should be the key containing multiple elements in the Map, not the map

This error is due to the lack of gater and setter methods corresponding to the properties in the Java class.

 

This error is due to the emergence of a new cache, and the old cache is not configured with a read-only attribute, so it will write the cache to the hard disk for persistent storage by default, and our object-to-file persistent storage is not implemented. This error will be reported when serializing the interface, so we can choose to let the object implement the serialization interface, or solve this error by not setting the readonly value to true for the <cache> tag. We recommend using the second type of adding attributes. The way.

When starting SpringMVC, the sub-container cannot be started. The reason may be that the scope of the servlet is not set, causing the imported servlet to conflict with the servlet package that comes with Tomcat. Just add the scope of the servlet dependency in the pom dependency.  

No declaration for component-scan found

 A complete space life needs to be added at the end. The path cannot be missing. Check whether the path is correct.

 An error occurs when accessing the jsp file on the home page:

Just configure the following coordinates of jsp in the pom file. 

Guess you like

Origin blog.csdn.net/hssjsh/article/details/130450060