Issue
Here is where it fails.
The full error message looks like this:
#12 55.48 [ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.5.30:compile (compile) on project tool: Compilation failure #12 55.48 [ERROR] /workspace/app/src/main/kotlin/com/ob/tool/LoginController.kt:[7,17] Unresolved reference: http
package com.ob.tool
import org.apache.catalina.connector.Response
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.net.http.HttpResponse
@RestController
class LoginController {
@CrossOrigin(origins = ["http://localhost:8080"])
@PostMapping("/login")
fun login(@RequestBody user: User): ResponseEntity<Response> {
return if(user.username == "Admin" && user.password == "Admin4040") ResponseEntity(HttpStatus.OK) else ResponseEntity(HttpStatus.UNAUTHORIZED)
}
}
My Dockerfile/docker-compose looks like this:
FROM openjdk:8-jdk-alpine as build
WORKDIR /workspace/app
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
RUN ./mvnw install -DskipTests
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG DEPENDENCY=/workspace/app/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","hello.Application"]
version: "3.5"
services:
frontend:
build: ./frontend
ports:
- "8080:8080"
volumes:
- ./frontend/src:/App/src
backend:
build: ./backend
ports:
- "8081:8081"
volumes:
- ./backend/src:/App/src
Solution
The java.net.http
package was introduced in Java 11 as far as I know, but you're using JDK8 in your docker image.
That being said, you don't seem to be using java.net.http.HttpResponse
at all in the code, so you could just remove the import I believe.
Answered By - Joffrey