如題。我的專案中加入了dozer mapper,gradle 依賴:compile("net.sf.dozer:dozer:5.4.0")
,我沒有設定dozer.properties 這個文件,而是直接配置了一個javabean ,程式碼如下:
@Configuration public class DozerConfig { @Bean public DozerBeanMapperFactoryBean mapper() { return new DozerBeanMapperFactoryBean(); } }
,然後問題是:我每次啟動這個應用時,dozer都會去查找dozer.properties這個文件,耗時半分鐘左右,我有沒有辦法透過配置去掉這個查找過程?啟動日誌相關內容:
2017-06-06 20:57:49.908 [restartedMain] INFO o.s.b.c.e.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/] 2017-06-06 20:58:14.274 [restartedMain] INFO org.dozer.config.GlobalSettings - Trying to find Dozer configuration file: dozer.properties 2017-06-06 20:58:14.281 [restartedMain] WARN org.dozer.config.GlobalSettings - Dozer configuration file not found: dozer.properties. Using defaults for all Dozer global properties. 2017-06-06 20:58:14.283 [restartedMain] INFO org.dozer.DozerInitializer - Initializing Dozer. Version: 5.4.0, Thread Name: restartedMain
dozer的設定檔省略不了的,物件關係映射要定義在xml檔。如果你處在專案整合階段,你可以考慮使用mapstruct。