k8s测试镜像
k8s测试镜像Java代码DockerfileJava代码MainController@RestController@RequestMappingpublic class MainController {@Autowiredprivate AddService addService;@Value("${server.port}")private String port;@GetMapping("/
·
k8s测试镜像
Java代码
MainController
@RestController
@RequestMapping
public class MainController {
@Autowired
private AddService addService;
@Value("${server.port}")
private String port;
@GetMapping("/port")
public String getport(){
return port;
}
@GetMapping("/ip")
public String getip(){
String hostAddress="";
try {
InetAddress localHost = InetAddress.getLocalHost();
hostAddress = localHost.getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return hostAddress;
}
@GetMapping("/getfile")
public String getfile(){
String path="/home/zhangxujie/11.text";
StringBuffer sb=new StringBuffer();
BufferedReader in=null;
try {
in =new BufferedReader(new FileReader(path));
String line;
while ((line = in.readLine()) != null) {
sb.append(line+"\n");
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if (in!=null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return sb.toString();
}
}
application.properties
# 应用名称
spring.application.name=demo123
# 应用服务 WEB 访问端口
server.port=8080
# spring 静态资源扫描路径
spring.resources.static-locations=classpath:/static/
Dockerfile
Dockerfile
FROM 172.30.66.9/zxjxm/openjdk:v1
MAINTAINER zhangxujie
RUN mkdir -p /home/zhangxujie
ADD ./run_k8s.sh /
COPY ./demo123-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT [ "sh", "-c", "/run_k8s.sh" ]
run_k8s.sh
exec java -jar /app.jar
更多推荐
已为社区贡献1条内容
所有评论(0)