ABAP Netweaver, Hybris Commerce和SAP 云平臺的登錄認(rèn)證
1560
2025-04-01
我們可以用docker ps首先找到某個(gè)Docker容器的id,再使用關(guān)鍵字docker logs <容器id>打印出該容器產(chǎn)生的日志:
同樣,在宿主機(jī)目錄/var/lib/docker/containers下面,能發(fā)現(xiàn)一個(gè)文件夾,其前12位名稱正好是我們在命令docker ps里查看到的容器id:
進(jìn)入該文件夾,即可查找到以-json.log結(jié)尾的日志文件:
如何將SpringBoot應(yīng)用Docker化并部署到SAP云平臺?
首先需要把SpringBoot應(yīng)用打包成docker,我用的dockerfile內(nèi)容為:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
VOLUME /log
EXPOSE 8080
ADD target/prolikeService.jar app.jar
ENV JAVA_OPTS="-Dserver.port=8080"
ENTRYPOINT exec java $JAVA_OPTS -jar /app.jar
使用如下的命令行打包:
docker build -t i042416/springbootexample:v4 .
docker login登錄docker hub,將該鏡像上傳:
docker push i042416/springbootexample:v4
最后使用命令部署到SAP Cloud Platform上:
cf push jerryjavadocker --docker-image i042416/springbootexample:v4
命令執(zhí)行完畢后,能夠在SAP云平臺的控制臺里,看到這個(gè)成功部署的Docker應(yīng)用:
從控制臺里得到應(yīng)用url:
成功訪問:
SpringBoot里的官方文檔叫做Externalized Configuration:
優(yōu)先級依次如下:
(1) Devtools global settings properties in the $HOME/.config/spring-boot folder when devtools is active.
(2) @TestPropertySource annotations on your tests.
(3) properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your Application.
(4) Command line arguments.
(5) Properties from SPRING_Application_JSON (inline JSON embedded in an environment variable or system property).
(6) ServletConfig init parameters.
(7) ServletContext init parameters.
(8) JNDI attributes from java:comp/env.
(9) Java System properties (System.getProperties()).
(10) OS environment variables.
(11) A RandomValuePropertySource that has properties only in random.*.
(12) Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
(13) Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
(14) Application properties outside of your packaged jar (application.properties and YAML variants).
(15) Application properties packaged inside your jar (application.properties and YAML variants).
(16) @PropertySource annotations on your @Configuration classes. Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
(17) Default properties (specified by setting SpringApplication.setDefaultProperties).
做個(gè)實(shí)驗(yàn),在run as configuration里,program argument設(shè)置為server.port=8001,
Environment環(huán)境變量設(shè)置為server.port=8002.
在SpringBoot項(xiàng)目內(nèi)部的Application.properties文件設(shè)置成8000:
最后運(yùn)行時(shí),生效的端口是環(huán)境變量設(shè)置進(jìn)去的8002:
在shell里使用set命令設(shè)置環(huán)境變量,也能按照期望的方式工作:
Docker 鏡像服務(wù)
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。