Rate This Document
Findability
Accuracy
Completeness
Readability

Errors of SampleOAuth2ClientApplicationTests.java Reported When Compiling Spring Boot

Symptom

The message "UnKnownHostException: api.login.yahoo.com" is displayed when "api.login.yahoo.com" 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

  1. Open the SampleOAuth2ClientApplicationTests.java file.
    vim ./spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java
  2. Press i to enter the insert mode and modify the file.
    1. Add the following content below line 20:
      import java.util.Properties;

    2. Insert the following code from line 39:
         static {
                      Properties props = System.getProperties();
                      props.put("http.proxyHost", "127.0.0.1");
                      props.put("http.proxyPort", "3128");
                      props.put("https.proxyHost", "127.0.0.1");
                      props.put("https.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.

      Run the :set list command to check the format. Spaces are not allowed. Use Tab to indent the code.

  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Recompile Spring Boot.