Spring-boot-gradle-plugin Failed to Pull Compilation Dependencies
Symptom
The message "UnKnownHostException" is displayed when "repo.maven.apache.org" is accessed during the Spring Boot compilation.
Key Process and Cause Analysis
The host is not mapped. Add proxy configurations to solve the problem.
Conclusion and Solution
- Open the GradleBuild.java file.
vim ./spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java
- Press i to enter the insert mode and modify the following content.
- Add the following content after line 114:
String[] newArguments = new String[arguments.length + 4]; System.arraycopy(arguments, 0, newArguments, 0, arguments.length); newArguments[arguments.length] = "-Dhttp.proxyHost=127.0.0.1"; newArguments[arguments.length + 1] = "-Dhttp.proxyPort=3128"; newArguments[arguments.length + 2] = "-Dhttps.proxyHost=127.0.0.1"; newArguments[arguments.length + 3] = "-Dhttps.proxyPort=3128";In the preceding example, 127.0.0.1 and 3128 indicate the IP address and port number of the proxy host. Replace them with the actual ones.
- Modify the content in line 121 as follows:
BuildResult result = prepareRunner(newArguments).build();
- Add the following content after line 135:
String[] newArguments = new String[arguments.length + 4]; System.arraycopy(arguments, 0, newArguments, 0, arguments.length); newArguments[arguments.length] = "-Dhttp.proxyHost=127.0.0.1"; newArguments[arguments.length + 1] = "-Dhttp.proxyPort=3128"; newArguments[arguments.length + 2] = "-Dhttps.proxyHost=127.0.0.1"; newArguments[arguments.length + 3] = "-Dhttps.proxyPort=3128";In the preceding example, 127.0.0.1 and 3128 indicate the IP address and port number of the proxy host. Replace them with the actual ones.
- Add the following content below line 140:
return prepareRunner(newArguments).buildAndFail();

Run the :set list command to check the format. Spaces are not allowed. Use Tab to indent the code.
- Add the following content after line 114:
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Recompile Spring Boot.
Parent topic: Troubleshooting