Skip to content

Commit

Permalink
deploy: 97f3ec0
Browse files Browse the repository at this point in the history
  • Loading branch information
l10178 committed Oct 18, 2023
1 parent fd2d72f commit 99e6e2c
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/guides/migrating-spring-to-spring-boot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</span></span><span class=line><span class=cl><span class=kd>public</span> <span class=kt>void</span> <span class=nf>handlerPropertiesChangeEvent</span><span class=o>(</span><span class=n>RefreshScopeRefreshedEvent</span> <span class=n>event</span><span class=o>)</span> <span class=o>{</span>
</span></span><span class=line><span class=cl> <span class=c1>//此时配置 Bean 已刷新完成,处理自己的业务逻辑
</span></span></span><span class=line><span class=cl><span class=c1></span><span class=o>}</span>
</span></span></code></pre></div></li></ol><h2 id=jar-方式运行>jar 方式运行<a href=#jar-方式运行 class=anchor aria-hidden=true>#</a></h2><p>如果不使用外置 Tomcat,使用 <code>java -jar</code> 方式直接运行,首先打包模式为 jar 并在发布时增加环境变量 <code>SPRING_BOOT_JAR_APP=true</code></p><p>与外置 Tomcat 模式差别:</p><ol><li>jar 模式一个 pod 内只能部署一个模块,不支持多模块合并部署。</li><li>jar 模式不会自动把 jar 解压成文件夹(war 模式会),所以关于文件资源的读写要特别注意,参考下面的问题描述章节。</li></ol><h2 id=老项目迁移升级步骤>老项目迁移升级步骤<a href=#老项目迁移升级步骤 class=anchor aria-hidden=true>#</a></h2><ol><li>改 pom.xml:修改 parent,引入必须的 starter,删除所有关于 Spring/logback/junit 的依赖项(由 Spring Boot Starter 自动引入),插件切换到 spring-boot-maven-plugin。</li><li>原有的 xml 配置,可以改为注解形式,也可以不改直接 <code>@ImportResource</code> 使用。</li><li>注意配置扫描范围,原来 xml 中可能是配置是某几个包,Spring Boot 默认扫描 Application.java 所在包,范围可能扩大。</li><li>删除原来 web.xml 相关配置,如果有额外的 filter、servlet,需要额外定义 Bean 注入。</li><li>Unit Test 更换注解,目前默认 junit 版本是 junit5,原 junit4 注解有较大变更,详细请参考下面的参考资料。</li></ol><h3 id=迁移辅助工具>迁移辅助工具<a href=#迁移辅助工具 class=anchor aria-hidden=true>#</a></h3><ul><li><p><a href=https://github.com/adoptium/emt4j>EMT4J</a></p><p>通过静态扫描指导从 Java 8 升级到 Java 17 需要注意的变更项。</p></li><li><p><a href=https://github.com/spring-projects-experimental/spring-boot-migrator>spring-boot-migrator</a></p><p>Spring Boot 迁移工具,通过扫描输出 从 Spring 到 Spring Boot,以及 Spring Boot 3 迁移指导意见。</p></li></ul><h3 id=war-配置转移>War 配置转移<a href=#war-配置转移 class=anchor aria-hidden=true>#</a></h3><p>If you try to migrate a Java legacy application to Spring Boot you will find out that <a href=https://github.com/spring-projects/spring-boot/issues/2175>Spring Boot ignores
</span></span></code></pre></div></li></ol><h2 id=jar-方式运行>jar 方式运行<a href=#jar-方式运行 class=anchor aria-hidden=true>#</a></h2><p>如果不使用外置 Tomcat,使用 <code>java -jar</code> 方式直接运行,首先打包模式为 jar 并在发布时增加环境变量 <code>SPRING_BOOT_JAR_APP=true</code></p><p>与外置 Tomcat 模式差别:</p><ol><li>jar 模式一个 pod 内只能部署一个模块,不支持多模块合并部署。</li><li>jar 模式不会自动把 jar 解压成文件夹(war 模式会),所以关于文件资源的读写要特别注意,参考下面的问题描述章节。</li></ol><h2 id=老项目迁移升级步骤>老项目迁移升级步骤<a href=#老项目迁移升级步骤 class=anchor aria-hidden=true>#</a></h2><ol><li>改 pom.xml:修改 parent,引入必须的 starter,删除所有关于 Spring/logback/junit 的依赖项(由 Spring Boot Starter 自动引入),插件切换到 spring-boot-maven-plugin。</li><li>原有的 xml 配置,可以改为注解形式,也可以不改直接 <code>@ImportResource</code> 使用。</li><li>注意配置扫描范围,原来 xml 中可能是配置是某几个包,Spring Boot 默认扫描 Application.java 所在包,范围可能扩大。</li><li>删除原来 web.xml 相关配置,如果有额外的 filter、servlet,需要额外定义 Bean 注入。</li><li>Unit Test 更换注解,目前默认 junit 版本是 junit5,原 junit4 注解有较大变更,详细请参考下面的参考资料。</li></ol><h3 id=迁移辅助工具>迁移辅助工具<a href=#迁移辅助工具 class=anchor aria-hidden=true>#</a></h3><ul><li><p><a href=https://github.com/adoptium/emt4j>EMT4J</a></p><p>通过静态扫描指导从 Java 8 升级到 Java 17 需要注意的变更项。</p></li><li><p><a href=https://github.com/apache/tomcat-jakartaee-migration>tomcat-jakartaee-migration</a></p><p>Tomcat 9 到 10 迁移辅助工具。</p></li><li><p><a href=https://github.com/spring-projects-experimental/spring-boot-migrator>spring-boot-migrator</a></p><p>Spring Boot 迁移工具,通过扫描输出 从 Spring 到 Spring Boot,以及 Spring Boot 3 迁移指导意见。</p></li></ul><h3 id=war-配置转移>War 配置转移<a href=#war-配置转移 class=anchor aria-hidden=true>#</a></h3><p>If you try to migrate a Java legacy application to Spring Boot you will find out that <a href=https://github.com/spring-projects/spring-boot/issues/2175>Spring Boot ignores
the web.xml file</a> when it is run as embedded container.</p><p>webapp web.xml 配置如何转移到 spring boot war 形式。
参考:<a href=https://www.baeldung.com/spring-boot-dispatcherservlet-web-xml>https://www.baeldung.com/spring-boot-dispatcherservlet-web-xml</a></p><h2 id=遇见问题及解决方案>遇见问题及解决方案<a href=#遇见问题及解决方案 class=anchor aria-hidden=true>#</a></h2><p>下面记录一些比较常见的问题,更多问题请参考下面章节中的参考资料,里面的问题很有参考价值。</p><ul><li><p>com.google.common.io.Resources#getResource 无法获取到 jar 包内资源</p><p>如果是 <code>java -jar</code> 模式运行, <code>Thread.currentThread().getContextClassLoader().getResource(resourceName)</code> 形式的调用都无法获取 jar 包内资源,可考虑使用 <code>InputStream resourceFile = getClass().getResourceAsStream(resourceName);</code> 方式代替。</p></li><li><p>PostConstruct 和 PreDestroy 注解不生效</p><p>参考链接 <a href=https://stackoverflow.com/questions/18161682/why-is-postconstruct-not-called>https://stackoverflow.com/questions/18161682/why-is-postconstruct-not-called</a> 先逐个排除。<br>我所遇到的原因:PostConstruct、PreDestroy 等注解可能存在多个实现或者过个版本,比如以下 jar 包都可能包含:</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go> javax.annotation-api-1.3.2.jar
</span></span></span><span class=line><span class=cl><span class=go> jakarta.annotation-api-1.3.5.jar
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
2 changes: 1 addition & 1 deletion docs/reference/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
2 changes: 1 addition & 1 deletion docs/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
2 changes: 1 addition & 1 deletion search-index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sitemap.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>/zh/sitemap.xml</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod></sitemap></sitemapindex>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>/zh/sitemap.xml</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod></sitemap></sitemapindex>
2 changes: 1 addition & 1 deletion zh/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/blog/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/privacy/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/java/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/java/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/spring-boot/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/spring-boot/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/</loc><lastmod>2023-10-18T09:10:18+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/contributors/</loc><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"><url><loc>/docs/guides/introduction/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/blog/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/migrating-spring-to-spring-boot/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/spring-boot-micrometer/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/guides/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/reference/example/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/docs/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/privacy/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/java/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/java/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/spring-boot/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/categories/spring-boot/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/tags/</loc><lastmod>2023-10-18T09:28:54+08:00</lastmod><changefreq>monthly</changefreq><priority>0.5</priority></url><url><loc>/contributors/</loc><changefreq>monthly</changefreq><priority>0.5</priority></url></urlset>

0 comments on commit 99e6e2c

Please sign in to comment.