application properties配置8083端口后仍提示8080占用的解决方法
Hey there, let's troubleshoot why your application is still clinging to port 8080 even though you've set server.port=8083 in your config file. Here are the most common fixes to get it up and running on your desired port:
Double-check your configuration file details
First, make sure you're working with the right file and location:- Confirm the filename is
application.properties(note the dot, not a space—typos here are way too common!). - Verify it’s placed directly in the
src/main/resourcesdirectory (not nested in a subfolder, which would stop Spring from picking it up by default). - If you’re using Spring profiles (like dev/prod), check if an environment-specific config file (e.g.,
application-dev.properties) is overriding the main one—you’ll need to setserver.port=8083in the active profile’s file too.
- Confirm the filename is
Check for overriding startup parameters
Command-line or IDE launch settings can easily override your config file:- If you’re starting the app via a JAR command, look for something like
--server.port=8080in the arguments. Remove that or swap it to--server.port=8083. - In your IDE (IntelliJ, Eclipse, etc.), open your Run/Debug configuration. Check the Program arguments or VM options sections for
-Dserver.port=8080—update this to8083if it’s present.
- If you’re starting the app via a JAR command, look for something like
Clean and rebuild your project
Stale build artifacts or IDE caches can prevent config changes from taking effect:- For Maven projects, run
mvn clean installin your terminal to wipe old builds and generate fresh ones. - For Gradle projects, use
./gradlew clean build. - Restart your IDE and clear its cache (e.g., in IntelliJ:
File > Invalidate Caches... > Invalidate and Restart).
- For Maven projects, run
Ensure port 8083 isn’t occupied
Even though the error mentions 8080, it’s worth confirming your target port is free:- Windows: Run
netstat -ano | findstr :8083to find the PID of the process using the port, then kill it withtaskkill /F /PID <your-pid>. - Linux/Mac: Use
lsof -i :8083ornetstat -tulpn | grep :8083to locate the process, then terminate it withkill -9 <your-pid>.
- Windows: Run
Check for hardcoded ports in your code
Sometimes developers hardcode ports in configuration classes or the main application file:- Search your codebase for instances of
server.portor direct port assignments (e.g., in a@Configurationclass). Make sure these are either removed or set to read from yourapplication.propertiesfile.
- Search your codebase for instances of
内容的提问来源于stack exchange,提问作者Trts

