Spring注解:@Profile

2025-12-30 03:17:09

1、用java解决在Window系统和Linux系统下Word转Pdf问题。

2、首先是pom.xml:

Spring注解:@Profile

3、然后创建一个接口(IDocumentConvert),两个实现类LinuxWordToPdf和WindowWordToPdf,如下

Spring注解:@Profile

Spring注解:@Profile

Spring注解:@Profile

4、然后利用@Configuration注解,配置创建一Spring配置类:ProfileConfig

Spring注解:@Profile

5、最后,创建测试类ProfileTest

Spring注解:@Profile

Spring注解:@Profile

6、在web项目中,通过使用spring.profiles.activespring.profiels.default

来指定激活哪个profile,spring.profiles.active的优先级高,如果没有设置这两个属性,则不创建@profile对应的bean

方式:

    作为DispatcherServlet的初始化参数;

    在集成测试类上,使用@ActiveProfiles注解设置;

    作为Web应用的上下文参数;

    作为JNDI条目;

    作为环境变量;

    作为JVM的系统属性;

其实我也就明白前三种。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢