pom
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!----> <groupId>com.iflytek.pu.spart</groupId> <artifactId>zx_cloud_start</artifactId> <version>1.0.0</version> <properties> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <spring-cloud.version>2021.0.1</spring-cloud.version> <spring-boot.version>2.6.6</spring-boot.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> <skipTests>true</skipTests> <elasticsearch.version>7.16.2</elasticsearch.version> <mybatis-plus.version>3.4.2</mybatis-plus.version> </properties> <dependencyManagement> <dependencies> <dependency> <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!--nacos配置中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>2.2.6.RELEASE</version> </dependency> <!--nacos注册中心--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>2.2.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </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-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>${spring-boot.version}</version> </dependency> <!--swagger依赖, 3.0.2版本会报错--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>3.0.3</version> <exclusions> <exclusion> <artifactId>swagger-models</artifactId> <groupId>io.swagger</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> <!--配置文件加密--> <dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>2.0.0</version> </dependency> <!--fastjson--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.47</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.13</version> </dependency> <!--Mybaties依赖--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>${mybatis-plus.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-annotation</artifactId> <version>${mybatis-plus.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.44</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> </dependency> <!-- poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.3</version> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> <!-- 导入导出 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>3.1.1</version> </dependency> <!--mybatis-plus 代码生成器依赖--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.3.1.tmp</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> </dependencies> <build> <!-- <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <target>${java.version}</target> <source>${java.version}</source> <encoding>UTF-8</encoding> </configuration> </plugin> <!– 设置maven打包插件的编码 –> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.6</version> <configuration> <jvmArguments>-Dfile-encoding=UTF-8</jvmArguments> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!– 设置maven打包插件的编码 –> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> </plugin> </plugins>--> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <!-- <useProjectArtifact>false</useProjectArtifact> --> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <!-- <executions> <execution> <phase>package</phase> <goals> <goal>test-jar</goal> </goals> </execution> </executions> --> </plugin> </plugins> </build> </project>
bootstrap
spring: application: name: znbb-web-wwlu profiles: active: dev cloud: nacos: discovery: server-addr: ${spring.cloud.nacos.server-addr} enabled: false # 禁用服务发现 register-enabled: false # 禁用注册 config: server-addr: ${spring.cloud.nacos.server-addr} #nacos服务地址 enabled: false # 禁用配置 refresh-enabled: true #修改后自动加载 timeout: 3000 group: DEFAULT_GROUP #nacos配置文件所选择的group prefix: ${spring.application.name} file-extension: properties shared-configs: # 共用的配置 - data-id: znbb-web-common1 group: znbb refresh: true - data-id: znbb-web-common2 group: znbb refresh: true
application.properties
server.port=8098 #====================================kafka相关配置============================================= ######################### # default kafka consumer config ######################### kafka.consumer[session.timeout.ms]=30000 kafka.consumer[request.timeout.ms]=600000 kafka.consumer[enable.auto.commit]=false kafka.consumer[auto.offset.reset]=earliest kafka.consumer[fetch.max.bytes]=52428800 kafka.consumer[max.partition.fetch.bytes]=31457280 kafka.consumer[max.poll.records]=1000 kafka.consumer[key.deserializer]=org.apache.kafka.common.serialization.StringDeserializer kafka.consumer[value.deserializer]=org.apache.kafka.common.serialization.StringDeserializer ######################### # kafka consumer config ######################### kafka.consumerConcurrency=16 kafka.poolTimeout=6000 kafka.consumer[bootstrap.servers]=${kafka.servers} kafka.consumer[group.id]=label-web ######################### # default kafka producer config ######################### kafka.producer[retries]=3 kafka.producer[max.request.size]=10485760 kafka.producer[key.serializer]=org.apache.kafka.common.serialization.StringSerializer kafka.producer[value.serializer]=org.apache.kafka.common.serialization.StringSerializer ######################### # kafka producer configgeerEnable ######################### kafka.producer[bootstrap.servers]=${kafka.servers} kafka.producer[batch.size]=16 kafka.producer[request.timeout.ms]=600000 kafka.servers=10.3.143.187:9092 ######################### # mybatis config ######################### mybatis-plus.typeAliasesPackage= com.iflytek.dyqb.data.entity mybatis-plus.mapperLocations= classpath*:mapper/*.xml mybatis-plus.configuration.mapUnderscoreToCamelCase=true mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.lazy-loading-enabled=true # 路径匹配 spring.mvc.pathmatch.matching-strategy= ant_path_matcher spring.servlet.multipart.location=/iflytek/tomcatTmp ######################### # mysql config ######################### mysql.ip=10.3.143.75 mysql.port=3306 mysql.name=ry mysql.username=root mysql.password=iflytek # 数据库连接ip database.ip=${mysql.ip} # 数据库链接端口 database.port=${mysql.port} # 数据库名称 database.name=${mysql.name} # 数据库用户名 database.username=${mysql.username} # 数据库密码 database.password=${mysql.password} spring.datasource.druid.url=jdbc:mysql://${database.ip}:${database.port}/${database.name}?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true spring.datasource.druid.driver-class-name=com.mysql.jdbc.Driver spring.datasource.druid.username=${database.username} spring.datasource.druid.password=${database.password} ######################### # redis config ######################### # redis 配置 # Redis数据库索引(默认为0) spring.redis.database=0 # Redis服务器地址 spring.redis.host=localhost # Redis服务器连接端口 spring.redis.port=6379 # Redis服务器连接密码(默认为空) spring.redis.password=
swagger
package com.iflytek.config; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType; import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver; import org.springframework.boot.actuate.endpoint.web.EndpointMapping; import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier; import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier; import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier; import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import java.util.ArrayList; import java.util.Collection; import java.util.List; @Configuration @EnableKnife4j public class SwaggerConfig { @Value("${swagger.enabled:false}") private boolean enabled; @Value("${server.port:17201}") private String port; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .enable(enabled) .useDefaultResponseMessages(false) .apiInfo(apiInfo()) .groupName("dev") .select() .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("SZP-WEB接口文档") .description("接口说明文档") .termsOfServiceUrl("http://ip:" + port + "/**") .contact(new Contact("szp", "", "")) .version("1.0.0") .build(); } /** * 解决springboot2.6.x集成swagger报错 * * @param webEndpointsSupplier * @param servletEndpointsSupplier * @param controllerEndpointsSupplier * @param endpointMediaTypes * @param corsProperties * @param webEndpointProperties * @param environment * @return */ @Bean public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier , ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier , EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties , WebEndpointProperties webEndpointProperties, Environment environment) { List allEndpoints = new ArrayList<>(); Collection webEndpoints = webEndpointsSupplier.getEndpoints(); allEndpoints.addAll(webEndpoints); allEndpoints.addAll(servletEndpointsSupplier.getEndpoints()); allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints()); String basePath = webEndpointProperties.getBasePath(); EndpointMapping endpointMapping = new EndpointMapping(basePath); boolean shouldRegisterLinksMapping = webEndpointProperties.getDiscovery().isEnabled() && (org.springframework.util.StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT)); return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration() , new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping); } }
标签:项目,新建,spring,boot,springframework,kafka,import,org,模板 From: https://www.cnblogs.com/JYB2021/p/18146638