Code Monkey home page Code Monkey logo

spring-boot-api-seedling's Introduction

Spring Boot API Seedling

stars license

English | 简体中文

Introduction

Modified from: spring-boot-api-project-seed

The original project is very well and has been able to meet many basic needs. Thanks the seed author!

Seedling project: I continued to add some small functions according to my needs, such as API signature authentication, API documents, some tools, etc.

The added content includes:

  • Spring Cache: To cache
  • Redis: Cache middleware
  • Swagger3:API Doc
  • Spring Security + JWT:Sign the caller authentication
  • Jasypt:Encryption configuration
  • etc.

The code specification refers to the《Alibaba Java Development》 and install the Alibaba Java Coding Guidelines plugin.

The style specification refers to Google and install google-java-format plugin.

Annotation tool: Lombok, install the Idea plugin of the same name.

Version

Dependencies Version
Java 1.8
SpringBoot 2.3.5

Start

# Clone project

git clone https://github.com/Zoctan/spring-boot-api-seedling.git

# Configure code generator

configure package test/java/.../CodeGenerator, import directory test/resources/sql/dev/*.sql file

# Generate code from database schema

input table name, run CodeGenerator.main() method to generate basic code (watch demo video)

# Last

configure the development environment configuration file application-dev.properties and start the project.

Have Fun Too:)

Related project

Update log

2021-11-19 Update Test Junit4 -> Junit5, update other dependencies version.

2020-11-09 Update Swagger2 to Swagger3, update other dependencies version.

2019-08-13 Modify Tomcat to Jetty, read RSA file error have been fixed, add file upload controller, update dependencies version.

2018-11-29 Modify setting file format to yml, improve unit testing, update dependencies version.

2018-07-21 Add Jasypt custom setting and password encryption, add Tomcat pack, modify RSA tool.

2018-07-15 Add DTO to prevent DO pollution.

2018-07-11 Add annotation for customizable cache expiration time, modify the data table user to account.

spring-boot-api-seedling's People

Contributors

moshuying avatar zoctan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-api-seedling's Issues

如果以jar方式启动无法读取rsa证书文件

原代码(无法读取):

 private byte[] replaceAndBase64Decode(
 final String file, final String headReplace, final String tailReplace) throws Exception {
    // 从 classpath:resources/ 中加载资源
    final ResourceLoader loader = new DefaultResourceLoader();
    final File f = loader.getResource(file).getFile();
    final FileInputStream fis = new FileInputStream(f);
    final DataInputStream dis = new DataInputStream(fis);
    final byte[] keyBytes = new byte[(int) f.length()];
    dis.readFully(keyBytes);
    dis.close();

    final String keyPEM =
       new String(keyBytes).replace(headReplace, "").trim().replace(tailReplace, "").trim();

   return Base64.decodeBase64(keyPEM);

}

更改后的代码:

 private byte[] replaceAndBase64Decode(
        final String file, final String headReplace, final String tailReplace) throws Exception {
    // 从 classpath:resources/ 中加载资源
    final ClassPathResource resource = new ClassPathResource(file);
    final InputStream fis = resource.getInputStream();
    final byte[] keyBytes = IOUtils.toByteArray(fis);
    final String keyPEM =
            new String(keyBytes).replace(headReplace, "").trim().replace(tailReplace, "").trim();

    return Base64.decodeBase64(keyPEM);
}

entity 主键生成问题

将entity主键生成方式改为
@GeneratedValue(strategy = GenerationType.TABLE, generator = "account_id_gen" )
@TableGenerator(name = "account_id_gen", table = "generator_table", pkColumnName = "gen_name", valueColumnName = "next_val", pkColumnValue = "user_account_id_gen", initialValue = 1000, allocationSize = 1 )
启动的时候报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountMapper' AccountMapper.class]: Invocation of init method failed; nested exception is tk.mybatis.mapper.MapperException: tk.mybatis.mapper.MapperException: tk.mybatis.mapper.MapperException: userAccountId - 该字段@GeneratedValue配置只允许以下几种形式: 1.useGeneratedKeys的@GeneratedValue(generator=\"JDBC\") 2.类似mysql数据库的@GeneratedValue(strategy=GenerationType.IDENTITY[,generator="Mysql"])

jwt token有效问题?

感谢作者的分享,很优秀的项目 。想问下 jwt token失效之后怎么在请求获取token, 如果用在生产这块逻辑怎么做呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.