pom配置文件,资源文件,源文件分离打包

3 篇文章 0 订阅
2 篇文章 0 订阅

 application.yml

server:
  port: 8088
  max-http-header-size: 10240

manage:
  swagger-open: false                # 是否开启swagger (true/false)
  kaptcha-open: false               # 是否开启登录时验证码 (true/false)
  spring-session-open: false        # 是否开启spring session, 如果是多机环境需要开启 (true/false)
  session-invalidate-time: 1800     # session失效时间(只在单机环境下生效, 多机环境在SpringSessionConfig类中配置) 单位:秒
  session-validation-interval: 900  # 多久检测一次失效的session(只在单机环境下生效) 单位:秒

beetl:
  resource-auto-check: false         # 热加载beetl模板, 开发时候用

spring:
  profiles:
    active: @spring.active@
  mvc:
    view:
      prefix: /pages
  devtools:
    restart:
      enabled: true
      additional-paths: src/main/java
      exclude: assets/**,pages/**
  servlet:
    multipart:
      max-request-size: 100MB
      max-file-size: 100MB
  main:
    allow-bean-definition-overriding: true

mybatis-plus:
  typeAliasesPackage: cn.cedar.manage.modular.system.model
  configuration:
    # log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl

log:
  path: manage-logs

 pom.xml

<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.1.RELEASE</version>
	</parent>
	<groupId>cn.cedar</groupId>
	<artifactId>manage</artifactId>
	<version>1.0.0</version>
	<name>manage-admin</name>
	<description>manage 的 spring boot 版本</description>
	<packaging>jar</packaging>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<jaxb-api>2.3.1</jaxb-api>
		<activation>1.1.1</activation>
		<shiro.version>1.4.0</shiro.version>
		<kaptcha.version>2.3.2</kaptcha.version>
		<ehcache3.version>3.6.3</ehcache3.version>
		<ehcache2.version>2.10.6</ehcache2.version>
		<beetl.version>2.9.3</beetl.version>
		<swagger.version>2.9.2</swagger.version>
		<ehcache.core.version>2.6.11</ehcache.core.version>
		<mysql-connector-java.version>8.0.11</mysql-connector-java.version>
		<jwt.version>0.9.0</jwt.version>
		<hutool-http.version>4.5.9</hutool-http.version>
		<hutool-crypto.version>4.5.9</hutool-crypto.version>
		<bcprov-jdk15on.version>1.61</bcprov-jdk15on.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcprov-jdk15on</artifactId>
			<version>${bcprov-jdk15on.version}</version>
		</dependency>
		<dependency>
			<groupId>cn.hutool</groupId>
			<artifactId>hutool-http</artifactId>
			<version>${hutool-http.version}</version>
		</dependency>
		<dependency>
			<groupId>cn.hutool</groupId>
			<artifactId>hutool-crypto</artifactId>
			<version>${hutool-crypto.version}</version>
		</dependency>
		<!-- jdk11 -->
		<!-- <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> 
			<version>${jaxb-api}</version> </dependency> -->
		<!--核心组件 -->
		<dependency>
			<groupId>cn.stylefeng.roses</groupId>
			<artifactId>kernel-core</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql-connector-java.version}</version>
		</dependency>
		<!--spring boot依赖 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-quartz</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-cache</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>
		<!--shiro依赖和缓存 -->
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-core</artifactId>
			<version>${shiro.version}</version>
			<exclusions>
				<exclusion>
					<artifactId>slf4j-api</artifactId>
					<groupId>org.slf4j</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-spring</artifactId>
			<version>${shiro.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-ehcache</artifactId>
			<version>${shiro.version}</version>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-api</artifactId>
				</exclusion>
				<exclusion>
					<groupId>net.sf.ehcache</groupId>
					<artifactId>ehcache-core</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>net.sf.ehcache</groupId>
			<artifactId>ehcache</artifactId>
			<version>${ehcache2.version}</version>
		</dependency>
		<!--验证码 -->
		<dependency>
			<groupId>com.github.penggle</groupId>
			<artifactId>kaptcha</artifactId>
			<version>${kaptcha.version}</version>
		</dependency>
		<!--beetl模板引擎 -->
		<dependency>
			<groupId>com.ibeetl</groupId>
			<artifactId>beetl</artifactId>
			<version>${beetl.version}</version>
		</dependency>
		<!--swagger -->
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>${swagger.version}</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>${swagger.version}</version>
		</dependency>
		<!--jwt token -->
		<dependency>
			<groupId>io.jsonwebtoken</groupId>
			<artifactId>jjwt</artifactId>
			<version>${jwt.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>
		<!-- 多数据源事务管理 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jta-atomikos</artifactId>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>5.1.3.RELEASE</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-test</artifactId>
		</dependency>
		<!--需要分布式session的话需要放开注释 -->
		<!--<dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session-data-redis</artifactId> 
			</dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> 
			</dependency> -->
	</dependencies>
	<!-- <build> -->
	<!-- <finalName>${project.artifactId}</finalName> -->
	<!-- <plugins> -->
	<!-- <plugin> -->
	<!-- <groupId>org.apache.maven.plugins</groupId> -->
	<!-- <artifactId>maven-compiler-plugin</artifactId> -->
	<!-- <version>3.8.0</version> -->
	<!-- </plugin> -->
	<!-- <plugin> -->
	<!-- <groupId>org.springframework.boot</groupId> -->
	<!-- <artifactId>spring-boot-maven-plugin</artifactId> -->
	<!-- <executions> -->
	<!-- <execution> -->
	<!-- <goals> -->
	<!-- <goal>repackage</goal> -->
	<!-- </goals> -->
	<!-- </execution> -->
	<!-- </executions> -->
	<!-- <configuration> -->
	<!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
	<!-- <fork>false</fork> -->
	<!-- </configuration> -->
	<!-- </plugin> -->
	<!-- <plugin> -->
	<!-- <groupId>org.apache.maven.plugins</groupId> -->
	<!-- <artifactId>maven-resources-plugin</artifactId> -->
	<!-- <configuration> -->
	<!-- <delimiters> -->
	<!-- <delimiter>@</delimiter> -->
	<!-- </delimiters> -->
	<!-- <useDefaultDelimiters>false</useDefaultDelimiters> -->
	<!-- </configuration> -->
	<!-- </plugin> -->
	<!-- </plugins> -->
	<!-- <resources> -->
	<!-- <resource> -->
	<!-- <directory>src/main/webapp</directory> -->
	<!-- </resource> -->
	<!-- <resource> -->
	<!-- <directory>src/main/resources</directory> -->
	<!-- <filtering>true</filtering> -->
	<!-- </resource> -->
	<!-- <resource> -->
	<!-- <directory>src/main/java</directory> -->
	<!-- <includes> -->
	<!-- <include>**/*.xml</include> -->
	<!-- </includes> -->
	<!-- </resource> -->
	<!-- </resources> -->
	<!-- </build> -->

	<build>
		<finalName>${project.artifactId}</finalName>
		<sourceDirectory>src/main/java</sourceDirectory>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>*</include>
				</includes>
				<filtering>true</filtering>
			</resource>

			<resource>
				<directory>src/main/webapp</directory>
				<includes>
					<include>*</include>
				</includes>
				<filtering>true</filtering>
			</resource>

			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
				</includes>
			</resource>
		</resources>

		<plugins>
			<!--打包jar -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<!--不打包资源文件 -->
					<excludes>
						<exclude>*.**</exclude>
						<exclude>*/*.xml</exclude>
					</excludes>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<!--MANIFEST.MF 中 Class-Path 加入前缀 -->
							<classpathPrefix>lib/</classpathPrefix>
							<!--jar包不包含唯一版本标识 -->
							<useUniqueVersions>false</useUniqueVersions>
							<!--指定入口类 -->
							<mainClass>cn.cedar.manage.ManageApplication</mainClass>
						</manifest>
						<manifestEntries>
							<!--MANIFEST.MF 中 Class-Path 加入资源文件目录 -->
							<Class-Path>./resources/ ./webapp/</Class-Path>
						</manifestEntries>
					</archive>
					<outputDirectory>${project.build.directory}</outputDirectory>
				</configuration>
			</plugin>

			<!--拷贝依赖 copy-dependencies -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>
								${project.build.directory}/lib/
							</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!--拷贝资源文件 copy-resources -->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<useDefaultDelimiters>false</useDefaultDelimiters>
							<delimiters>
								<delimiter>$[*]</delimiter> <!-- 需要识别$[*]来实现自动替换 -->
							</delimiters>

							<resources>
								<resource>
									<directory>src/main/resources</directory>
									<filtering>true</filtering>
									<includes>
										<include>**/*.xml</include>
										<include>**/*.yml</include>
									</includes>
								</resource>
							</resources>

							<resource>
								<directory>src/main/resources/</directory>
								<filtering>false</filtering>
								<excludes>
									<exclude>**/*.xml</exclude>
									<exclude>**/*.yml</exclude>
								</excludes>
							</resource>

							<nonFilteredFileExtensions>
								<nonFilteredFileExtension>woff</nonFilteredFileExtension>
								<nonFilteredFileExtension>woff2</nonFilteredFileExtension>
								<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
							</nonFilteredFileExtensions>
							<outputDirectory>${project.build.directory}/resources</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!--spring boot repackage,依赖 maven-jar-plugin 打包的jar包 重新打包成 spring boot 
				的jar包 -->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<!--重写包含依赖,包含不存在的依赖,jar里没有pom里的依赖 -->
					<includes>
						<include>
							<groupId>null</groupId>
							<artifactId>null</artifactId>
						</include>
					</includes>
					<layout>ZIP</layout>
					<!--使用外部配置文件,jar包里没有资源文件 -->
					<addResources>true</addResources>
					<outputDirectory>${project.build.directory}</outputDirectory>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
						<configuration>
							<!--配置jar包特殊标识 配置后,保留原文件,生成新文件 *-run.jar -->
							<!--配置jar包特殊标识 不配置,原文件命名为 *.jar.original,生成新文件 *.jar -->
							<!--<classifier>run</classifier> -->
						</configuration>
					</execution>
				</executions>
			</plugin>
			
			 <!-- 使用assembly.xml打包 -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>zip.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
			
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>local</id>
			<properties>
				<spring.active>local</spring.active>
			</properties>
		</profile>
		<profile>
			<id>dev</id>
			<properties>
				<spring.active>dev</spring.active>
			</properties>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
		</profile>
		<profile>
			<id>server</id>
			<properties>
				<spring.active>server</spring.active>
			</properties>
		</profile>
	</profiles>

	<repositories>
		<repository>
			<id>central</id>
			<url>https://mirrors.huaweicloud.com/repository/maven/</url>
		</repository>
	</repositories>
</project>

zip.xml 

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
	<id>dis</id>
	<formats>
		<format>zip</format>
	</formats>

	<fileSets>
		<fileSet>
			<directory>src/main/resources</directory>
			<outputDirectory>resources</outputDirectory>
			<filtered>true</filtered> <!-- filtered属性设置为true,可以将配置文件中的的变量替换为pom文件中的变量值 -->
		</fileSet>
		
		<fileSet>
			<directory>src/main/webapp</directory>
			<outputDirectory>webapp</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>${project.build.directory}</directory>
			<includes>
				<include>${project.build.finalName}.${project.packaging}</include>
			</includes>
			<outputDirectory>\</outputDirectory>
		</fileSet>
	</fileSets>

	<dependencySets>
		<dependencySet>
			<useProjectArtifact>false</useProjectArtifact>
			<outputDirectory>lib</outputDirectory>
			<scope>runtime</scope>
		</dependencySet>
	</dependencySets>
</assembly>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值