新西兰服务器

jspXCMS如何配置文件


jspXCMS如何配置文件

发布时间:2022-01-19 17:23:59 来源:高防服务器网 阅读:77 作者:iii 栏目:开发技术

本篇内容介绍了“jspXCMS如何配置文件”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

配置文件目录

/src/main/resources/conf/plugin

二次开发的核心就是配置文件,通过配置文件将不同模块和插件整合到一起。可以在这个目录下新建自己的文件夹,如:abc、novel等,本例为plug,即/src/main/resources/conf/plugin/plug。

Spring配置自动加载

配置文件目录及其子目录下文件名为context*.xml的配置文件会自动加载为Spring的WebApplicationContext。

触发自动加载的类是com.jspxcms.core.Application,相关代码为:@ImportResource({ "classpath:conf/**/context*.xml", "classpath:custom.xml" })。

本例的配置文件/src/main/resources/conf/plugin/plug/context.xml,符合自动加载规则,文件中<bean class="com.jspxcms.plug.ContextConfig" />会加载该类中的配置。在这个类里分别加载了:

  • Entity:@EntityScan({ "com.jspxcms.plug.domain" })

  • Dao:@EnableJpaRepositories(basePackages = { "com.jspxcms.plug.repository" }, repositoryFactoryBeanClass = MyJpaRepositoryFactoryBean.class)

  • Service和前台Controller:@ComponentScan({ "com.jspxcms.plug.service.impl", "com.jspxcms.plug.web.fore" })

后台Controller配置自动加载

配置文件目录及其子目录下文件名为backend*.xml的配置文件会自动加载为后台Controller。

触发自动加载的类是com.jspxcms.core.BackendWebConfig,相关代码为:@ImportResource({ "classpath:conf/**/backend*.xml" })。

本例的配置文件/src/main/resources/conf/plugin/plug/backend.xml符合自动加载规则。

<context:component-scan base-package="com.jspxcms.plug.web.back" use-default-filters="false">    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>    <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>  </context:component-scan>

这个配置会自动加载com.jspxcms.plug.web.back包下所有带有Controller或ControllerAdvice注解的类。

conf.properties自动加载

前台模板Freemarker标签、国际化文件目录等配置在conf.properties中配置。

配置文件目录及其子目录下文件名为conf*.properties的文件会自动加载。

触发自动加载的类是com.jspxcms.core.ShiroConfig,相关代码为:loader.setValue("classpath:conf/plugin/**/conf*.properties", "classpath:conf/conf.properties");。

本例的配置文件/src/main/resources/conf/plugin/plug/conf.properties,符合自动加载规则。

menu.yml自动加载

后台功能菜单及权限由该文件配置。

配置文件目录及其子目录下文件名为menu*.yml的文件会自动加载。

触发自动加载的类是com.jspxcms.core.MenuConfig,相关代码为:appContext.getResources("classpath:conf/**/menu*.yml");

本例的配置文件/src/main/resources/conf/plugin/plug/menu.properties,符合自动加载规则。

“jspXCMS如何配置文件”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注高防服务器网网站,小编将为大家输出更多高质量的实用文章!

[微信提示:高防服务器能助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

[图文来源于网络,不代表本站立场,如有侵权,请联系高防服务器网删除]
[