SpringBoot项目配置来动态勾选开发环境

时间:2025-04-02 19:23:35
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="/POM/4.0.0" xmlns:xsi="http:///2001/XMLSchema-instance" xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0."> <modelVersion>4.0.0</modelVersion> <!--声明继承父模块(即root)模块--> <parent> <groupId></groupId> <artifactId>jxt</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <!--子模块信息--> <artifactId>jxt-oms</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <!--配置jdk版本及文件编码--> <properties> <>UTF-8</> <>UTF-8</> <>1.8</> </properties> <!-- 重点 --> <!-- 多环境配置节点 --> <profiles> <!--1. 开发环境--> <profile> <id>dev</id> <!-- 默认激活开发环境 --> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!--节点名称,可自定义名称,只要和properties中取的变量名一致即可--> <>dev</> <!--log文件的路径--> <>${}/logs/jxt/</> </properties> </profile> <!--2. 测试环境--> <profile> <id>test</id> <properties> <>test</> <>/home/jxt/logs/jxt/</> </properties> </profile> <!--3. 生产环境--> <profile> <id>prod</id> <properties> <>prod</> <>/home/jxt/logs/jxt/</> </properties> </profile> </profiles> <!--其它依赖组件--> <dependencies> <dependency> <groupId></groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.</version> </dependency> <dependency> <groupId></groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId></groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!--阿里巴巴数据库连接池--> <dependency> <groupId></groupId> <artifactId>druid</artifactId> <version>1.0.28</version> </dependency> <!--mysql驱动--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.46</version> </dependency> <!--swagger接口文档生成器配置--> <dependency> <groupId></groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>-chen</groupId> <artifactId>swagger-ui-layer</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId></groupId> <artifactId>guava</artifactId> <version>21.0</version> </dependency> <dependency> <groupId>.swagger2markup</groupId> <artifactId>swagger2markup</artifactId> <version>1.3.3</version> </dependency> <dependency> <groupId></groupId> <artifactId>asciidoctorj-pdf</artifactId> <version>1.5.0-alpha.10.1</version> </dependency> <dependency> <groupId></groupId> <artifactId>asciidoctorj</artifactId> <version>1.5.7</version> </dependency> </dependencies> <build> <!--配置文件--> <resources> <resource> <!--配置文件的路径--> <directory>src/main/resources</directory> <!-- Maven的资源过滤功能可以实现在构建时, 修改<includes>中的文件以“@xxx@”表示的属性,此处是关键--> <filtering>true</filtering> <!--指定配置文件类型--> <includes> <include></include> <!--${}即为当前激活的配置文件--> <include>application-${}.properties</include> <include>**/*.xml</include> <include>**/*.setting</include> <include>**/*.p12</include> </includes> </resource> </resources> <!--插件--> <plugins> <plugin> <groupId></groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> <!-- 过滤后缀为pem、pfx的证书文件 --> <nonFilteredFileExtensions> <nonFilteredFileExtension>pem</nonFilteredFileExtension> <nonFilteredFileExtension>pfx</nonFilteredFileExtension> <nonFilteredFileExtension>p12</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin> <!--若使用了swagger,以下是PDF和HTML文档生成器的插件配置--> <plugin> <groupId></groupId> <artifactId>asciidoctor-maven-plugin</artifactId> <version>1.5.7.1</version> <!-- Include Asciidoctor PDF for pdf generation --> <dependencies> <dependency> <groupId></groupId> <artifactId>asciidoctorj-pdf</artifactId> <version>1.5.0-alpha.10.1</version> </dependency> <dependency> <groupId></groupId> <artifactId>jruby-complete</artifactId> <version>9.1.17.0</version> </dependency> </dependencies> <!-- 通用文档生成器配置 --> <configuration> <sourceDirectory>D:\docs\markdown\generated</sourceDirectory> <sourceHighlighter>coderay</sourceHighlighter> <attributes> <toc>left</toc> </attributes> </configuration> <executions> <execution> <id>output-html</id> <phase>generate-resources</phase> <goals> <goal>process-asciidoc</goal> </goals> <configuration> <backend>html5</backend> <outputDirectory>D:\docs\markdown\generated\html</outputDirectory> </configuration> </execution> <execution> <id>output-pdf</id> <phase>generate-resources</phase> <goals> <goal>process-asciidoc</goal> </goals> <configuration> <backend>pdf</backend> <outputDirectory>D:\docs\markdown\generated\pdf</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>.swagger2markup</groupId> <artifactId>swagger2markup-maven-plugin</artifactId> <version>1.3.1</version> <configuration> <!--此处端口一定要是当前项目启动所用的端口--> <swaggerInput>http://localhost:8087/v2/api-docs</swaggerInput> <outputDir>D:\docs\markdown\generated</outputDir> <config> <!-- 除了ASCIIDOC之外,还有MARKDOWN和CONFLUENCE_MARKUP可选 --> <>ASCIIDOC</> </config> </configuration> </plugin> </plugins> </build> </project>