SpringBoot官方文档翻译(二十六):已知限制&LiveReload&全局设置

20.2.7 Known Limitations(已知限制)

1
2
3
4
Restart functionality does not work well with objects that are     
deserialized by using a standard ObjectInputStream. If you need
to deserialize data, you may need to use Spring’s ConfigurableObjectInputStream 
in combination with Thread.currentThread().getContextClassLoader().

重新启动功能不适用于那些通过使用标准的ObjectInputStream进行反序列化的对象。如果您需要反序列化数据,你可能需要使用Spring的ConfigurableObjectInputStream结合使用Thread.currentThread().getContextClassLoader()

1
2
3
Unfortunately, several third-party libraries deserialize without     
considering the context classloader. If you find such a problem,
you need to request a fix with the original authors.

不幸的是,一些第三方的库反序列化的时候未考虑容器类加载器。如果您发现了这个问题,您需要请求作者做相应的修改。

20.3 LiveReload

1
2
3
4
The spring-boot-devtools module includes an embedded LiveReload server     
that can be used to trigger a browser refresh when a resource is changed.
LiveReload browser extensions are freely available for Chrome, Firefox
and Safari from livereload.com.

spring-boot-devtools模块引入了内置LiveReload服务器,当一个资源发生改变时,能够触发浏览器自动刷新,LiveReload浏览器扩展对于Chrome和Firefox还有Safari提供免费支持(livereload.com)。

1
2
If you do not want to start the LiveReload server when your application     
runs, you can set the spring.devtools.livereload.enabled property to false.

如果您子在您的应用运行的时候不想启动LiveReload服务器,您可以通过spring.devtools.livereload.enabled属性来设置成false。

1
2
3
4
You can only run one LiveReload server at a time. Before starting your    
application, ensure that no other LiveReload servers are running. If
you start multiple applications from your IDE, only the first has
LiveReload support.

您一次只能运行一个LiveReload服务器。在启动您的应用之前,确保没有其他的LiveReload服务器在运行。如果您在IDE中运行多个应用,仅仅第一个运行的应用能够有LiveReload的效果。

20.4 Global Settings(全局设置)

1
2
3
4
5
6
You can configure global devtools settings by adding a file named     
.spring-boot-devtools.properties to your $HOME folder (note that
the filename starts with “.”). Any properties added to this file
apply to all Spring Boot applications on your machine that use
devtools. For example, to configure restart to always use a trigger
file, you would add the following property:

您可以通过增加名为.spring-boot-devtools.properties(注意文件名以.开头的)的文件到您的$HOME文件夹来配置全局的devtools设置。任何属性被增加到这个文件将会被应用生效到所有的您机器上使用devtools的Spring Boot应用中。举个例子,去配置重启使用一个触发文件,您可以增加如下属性:

~/.spring-boot-devtools.properties.

1
spring.devtools.reload.trigger-file=.reloadtrigger

分享到