首页 > 其他分享 >项目新建模板

项目新建模板

时间:2024-04-19 19:12:28浏览次数:29  
标签:项目 新建 spring boot springframework kafka import org 模板

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>
            &lt;!&ndash; 设置maven打包插件的编码 &ndash;&gt;
            <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>
            &lt;!&ndash; 设置maven打包插件的编码 &ndash;&gt;
            <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

相关文章

  • 艾拓琪光电&威灏光电携手无锡哲讯启动SAP ERP数字化转型项目,共创未来发展
    4月16日,艾拓琪光电&威灏光电携手SAP实施商无锡哲讯举行SAP数字化转型项目启动会,全面推动企业数智化转型。启动会受到双方企业高度重视,苏州艾拓琪总经理何总、安徽威灏光电总经理刘总,无锡哲讯总经理崔新华先生及全体项目团队成员出席本次SAPERP项目启动会。苏州艾拓琪光电有限......
  • 一个非常实用的H264视频解码器开源项目
    一个非常实用的H264视频解码器开源项目音视频开发技术 ​关注他 29人赞同了该文章一、前言:为了弄清楚H264整个解码流程,为此我专门按照H264标准文档《T-REC-H.264-201704-S!!PDF-E.pdf》,用C++实现了一个H264裸码流视频解码器,代码工程地址为:h......
  • 新建vite vue2 项目
    1.1创建项目注意:这里vite的版本采用2.8.0的,最新的版本创建后续会出现问题[email protected]后续,安装如图  创建好项目后依次运行以下命令//1.进入项目cdvite-vue2​//2.安装依赖npminstall​//3.启动项目npmrundev访问效果如下  1.2安装vite对vue2支持......
  • IDEA中创建一个Servlet项目的详细步骤
    以下是通过IDEA创建一个简单的JavaServlet示例,支持通过HTTP在浏览器中访问的详细步骤。1.创建项目打开IDEA,点击NEW创建一个新项目生成如下的目录结构设置Maven的路径,File—>settings—>输入mvn。 2.引入依赖我们所使用的Servlet是Tomcat的api,不是JDK,也就是说Servlet......
  • Springboot 下载模板
    文件路径在项目的resources下面  路径 resources/tempExcel/导入模板.xlsx后端代码:/***下载模板**@paramresponse*@throwsIOException*/@RepeatSubmit@PostMapping("/download/template")publicvoiddownloadTemplate(HttpServletResponseresponse)throws......
  • WPF项目使用日志
    提问WPF项目如何使用日志回答引入nugetlog4net加入配置特性[assembly:ThemeInfo(ResourceDictionaryLocation.None,//wherethemespecificresourcedictionariesarelocated//(usedifaresourceisnotfoundinthepage,//orapplicationresourcedict......
  • Codes 重新定义 SaaS 模式的研发项目管理平台开源版 4.5.3 发布
    一:简介   Codes重新定义SaaS模式= 云端认证+程序及数据本地安装+不限功能+30人免费    Codes 是一个 高效、简洁、轻量的一站式研发项目管理平台。包含需求管理,任务管理,测试管理,缺陷管理,自动化测试,cicd 等功能;Codes帮助企业加速融合研发、测试、运......
  • 【Docker】临时起意用docker在阿里云ECS上部署项目遇到的坑
    我的小项目用到了两个springboot搭建的模块,还有mysql,redis,rabbitmq。因为不了解docker中网络协议栈的隔离而导致一个简单的部署花了我一天时间。关于容器之间端口的映射,可以运行如下命令来查看:[root@iZwz9337zr98g77j7a141hZ~]#dockerps-aCONTAINERIDIMAGE......
  • Java项目调用 WebService
    Java项目调用WebService序言:原本接触和二开的Java项目都是使用Spring框架,并且使用的接口都是RestFul风格,今天有一个Kingdee项目是使用WSDL文件提供接口通过WebService的方式来进行接口方式的相互通讯;因为是第一次使用WebService方式,所以写下这篇文档留作参考记......
  • NL2SQL技术方案系列(1):NL2API、NL2SQL技术路径选择;LLM选型与Prompt工程技巧,揭秘项目落
    NL2SQL技术方案系列(1):NL2API、NL2SQL技术路径选择;LLM选型与Prompt工程技巧,揭秘项目落地优化之道NL2SQL基础系列(1):业界顶尖排行榜、权威测评数据集及LLM大模型(SpidervsBIRD)全面对比优劣分析[Text2SQL、Text2DSL]NL2SQL基础系列(2):主流大模型与微调方法精选集,Text2SQL经典算法......