├── lib ├── start.bat ├── status.bat ├── stop.bat ├── install.bat ├── restart.bat ├── uninstall.bat ├── run.bat ├── crudapi.bat ├── setJavaEnv.bat ├── crudapi.xml └── download.sh ├── src └── main │ ├── resources │ ├── schema.sql │ ├── static │ │ └── index.html │ ├── application.properties │ └── application-windows.properties │ └── java │ └── cn │ └── crudapi │ └── example │ ├── config │ ├── LoggingAspectConfiguration.java │ ├── DataSourceAspect.java │ ├── WebConfig.java │ └── LoggingAspect.java │ ├── CrudapiExampleApplication.java │ └── Swagger2SpringBoot.java ├── img ├── table.png ├── customer.png ├── relation.png ├── weixinqun.png ├── auth │ ├── basicAuth.png │ ├── jwtAuth.png │ ├── jwtLogin.png │ ├── jwtAuthorization.png │ └── basicAuthorization.png └── crudapiweixin.jpeg ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── LICENSE ├── .gitignore ├── settings.xml ├── API.md ├── README_CN.md ├── README.md ├── pom.xml ├── mvnw.cmd └── mvnw /lib/start.bat: -------------------------------------------------------------------------------- 1 | crudapi start 2 | pause -------------------------------------------------------------------------------- /lib/status.bat: -------------------------------------------------------------------------------- 1 | crudapi status 2 | pause -------------------------------------------------------------------------------- /lib/stop.bat: -------------------------------------------------------------------------------- 1 | crudapi stop 2 | pause -------------------------------------------------------------------------------- /lib/install.bat: -------------------------------------------------------------------------------- 1 | crudapi install 2 | pause -------------------------------------------------------------------------------- /lib/restart.bat: -------------------------------------------------------------------------------- 1 | crudapi restart 2 | pause -------------------------------------------------------------------------------- /lib/uninstall.bat: -------------------------------------------------------------------------------- 1 | crudapi uninstall 2 | pause 3 | -------------------------------------------------------------------------------- /lib/run.bat: -------------------------------------------------------------------------------- 1 | cd /d %~dp0 2 | java -jar "crudapi.jar" 3 | pause 4 | -------------------------------------------------------------------------------- /lib/crudapi.bat: -------------------------------------------------------------------------------- 1 | cd /d %~dp0 2 | java -jar "crudapi.jar" 3 | pause 4 | -------------------------------------------------------------------------------- /src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | ALTER SESSION SET CURRENT_SCHEMA=crudapi 2 | -------------------------------------------------------------------------------- /img/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/table.png -------------------------------------------------------------------------------- /img/customer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/customer.png -------------------------------------------------------------------------------- /img/relation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/relation.png -------------------------------------------------------------------------------- /img/weixinqun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/weixinqun.png -------------------------------------------------------------------------------- /img/auth/basicAuth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/auth/basicAuth.png -------------------------------------------------------------------------------- /img/auth/jwtAuth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/auth/jwtAuth.png -------------------------------------------------------------------------------- /img/auth/jwtLogin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/auth/jwtLogin.png -------------------------------------------------------------------------------- /img/crudapiweixin.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/crudapiweixin.jpeg -------------------------------------------------------------------------------- /img/auth/jwtAuthorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/auth/jwtAuthorization.png -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /img/auth/basicAuthorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crudapi/crudapi-example/HEAD/img/auth/basicAuthorization.png -------------------------------------------------------------------------------- /lib/setJavaEnv.bat: -------------------------------------------------------------------------------- 1 | echo %Path% 2 | 3 | SETX /M JAVA_HOME "C:\Program Files\Java\jdk1.8.0_202" 4 | 5 | SETX /M Path "C:\Program Files\Java\jdk1.8.0_202\bin;%Path%" 6 | 7 | pause 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | crudapi 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/crudapi.xml: -------------------------------------------------------------------------------- 1 | 2 | crudapi 3 | CRUDAPI 4 | This service runs crudapi. 5 | 6 | java 7 | -jar "%BASE%\crudapi.jar" 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021-present crudapi 2 | 3 | crudapi简介: 4 | 无需编程,通过配置自动生成crud增删改查RESTful API,提供后台Web管理UI。 5 | 基于主流的开源框架,拥有自主知识产权,支持二次开发,包括API和SDK两种方式。 6 | 7 | 收费情况: 8 | 1. SDK版永久免费(包括个人和商业使用),无功能限制。 9 | 2. 源码版包括所有完整源代码 10 | 11 | 商业付费用户保密协议: 12 | 1. crudapi源码和Jar包只能自己使用,不得转让给第三方,不得二次销售。 13 | 2. 基于crudapi二次开发的源码或产品也不能以crudapi名义转让或销售。 14 | 3. 一旦发现有上述违规行为,取消一切售后服务,情节严重者,依法追究法律责任。 15 | 16 | 免责声明: 17 | 用户不得将crudapi用于包括但不限于色情、暴力、反动、侵权等违法用途,否则用户承担相应的法律责任,与crudapi无关。 18 | -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/config/LoggingAspectConfiguration.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 6 | 7 | @Configuration 8 | @EnableAspectJAutoProxy 9 | public class LoggingAspectConfiguration { 10 | @Bean 11 | public LoggingAspect loggingAspect() { 12 | return new LoggingAspect(); 13 | } 14 | 15 | @Bean 16 | public DataSourceAspect dataSourceAspect() { 17 | return new DataSourceAspect(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | lib/*jar 36 | lib/*.gz 37 | 38 | src/main/resources/static/crudapi 39 | src/main/resources/static/mapapi 40 | 41 | *.exe -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/CrudapiExampleApplication.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | import org.springframework.boot.web.servlet.ServletComponentScan; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.scheduling.annotation.EnableAsync; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | @ComponentScan({"cn.crudapi", "cn.crudapi.example"}) 13 | @ServletComponentScan(basePackages = {"cn.crudapi"}) 14 | @EntityScan("cn.crudapi.core.entity") 15 | @EnableTransactionManagement 16 | @EnableAsync 17 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) 18 | public class CrudapiExampleApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(CrudapiExampleApplication.class, args); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | aliyun 5 | 6 | true 7 | 8 | 9 | 10 | aliyun 11 | https://maven.aliyun.com/repository/public 12 | 13 | 14 | 15 | 16 | aliyun-plugin 17 | https://maven.aliyun.com/repository/public 18 | 19 | true 20 | 21 | 22 | false 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | aliyunmaven 31 | * 32 | 阿里云公共仓库 33 | https://maven.aliyun.com/repository/public 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/config/DataSourceAspect.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example.config; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Pointcut; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import cn.crudapi.core.datasource.config.DataSourceContextHolder; 11 | 12 | 13 | @Aspect 14 | public class DataSourceAspect { 15 | private static final Logger log = LoggerFactory.getLogger(DataSourceAspect.class); 16 | 17 | @Pointcut("within(cn.crudapi.api.controller..*)") 18 | public void applicationPackagePointcut() { 19 | } 20 | 21 | @Around("applicationPackagePointcut()") 22 | public Object dataSourceAround(ProceedingJoinPoint joinPoint) throws Throwable { 23 | String dataSource = DataSourceContextHolder.getHeaderDataSource(); 24 | log.info("DataSourceContextHolder setDataSource = " + dataSource); 25 | DataSourceContextHolder.setDataSource(dataSource); 26 | try { 27 | return joinPoint.proceed(); 28 | } finally { 29 | log.info("DataSourceContextHolder cleanDataSource"); 30 | DataSourceContextHolder.cleanDataSource(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example.config; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.web.server.ConfigurableWebServerFactory; 9 | import org.springframework.boot.web.server.ErrorPage; 10 | import org.springframework.boot.web.server.WebServerFactoryCustomizer; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.http.HttpStatus; 14 | 15 | @Configuration 16 | public class WebConfig { 17 | private static final Logger log = LoggerFactory.getLogger(WebConfig.class); 18 | 19 | @Value("${crudapi.publicPath}") 20 | private String publicPath; 21 | 22 | @Bean 23 | public WebServerFactoryCustomizer webServerFactoryCustomizer(){ 24 | log.info("webServerFactoryCustomizer"); 25 | 26 | if (StringUtils.isEmpty(publicPath)) { 27 | publicPath = "crudapi"; 28 | } 29 | 30 | String crudapiHomePage = "/" + publicPath + "/index.html"; 31 | 32 | log.info("crudapiHomePage {}", crudapiHomePage); 33 | 34 | return factory -> { 35 | ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, crudapiHomePage); 36 | factory.addErrorPages(error404Page); 37 | }; 38 | } 39 | } -------------------------------------------------------------------------------- /lib/download.sh: -------------------------------------------------------------------------------- 1 | CRUDAPI_ADMIN_WEB_VERSION=1.6.2 2 | CRUDAPI_VERSION=1.6.2 3 | BASE_URL=https://download.crudapi.cn 4 | 5 | CRUDAPI_ADMIN_WEB_GZ_URL=$BASE_URL/npm/crudapi-admin-web/$CRUDAPI_VERSION/crudapi-admin-web-$CRUDAPI_VERSION.tar.gz 6 | CRUDAPI_CORE_JRA_URL=$BASE_URL/maven/crudapi/$CRUDAPI_VERSION/crudapi-core-$CRUDAPI_VERSION.jar 7 | CRUDAPI_API_JRA_URL=$BASE_URL/maven/crudapi/$CRUDAPI_VERSION/crudapi-api-$CRUDAPI_VERSION.jar 8 | CRUDAPI_SECURITY_JRA_URL=$BASE_URL/maven/crudapi/$CRUDAPI_VERSION/crudapi-security-$CRUDAPI_VERSION.jar 9 | CRUDAPI_REST_JRA_URL=$BASE_URL/maven/crudapi/$CRUDAPI_VERSION/crudapi-rest-$CRUDAPI_VERSION.jar 10 | CRUDAPI_WEIXIN_JRA_URL=$BASE_URL/maven/crudapi/$CRUDAPI_VERSION/crudapi-weixin-$CRUDAPI_VERSION.jar 11 | CRUDAPI_WINSE_URL=$BASE_URL/exe/WinSW-x64.exe.tar.gz 12 | 13 | echo "$CRUDAPI_ADMIN_WEB_GZ_URL" 14 | echo "$CRUDAPI_CORE_JRA_URL" 15 | echo "$CRUDAPI_API_JRA_URL" 16 | echo "$CRUDAPI_SECURITY_JRA_URL" 17 | echo "$CRUDAPI_REST_JRA_URL" 18 | echo "$CRUDAPI_WEIXIN_JRA_URL" 19 | echo "$CRUDAPI_WINSE_URL" 20 | 21 | rm -rf *.gz 22 | rm -rf *.jar 23 | 24 | curl -k -O $CRUDAPI_ADMIN_WEB_GZ_URL 25 | curl -k -O $CRUDAPI_CORE_JRA_URL 26 | curl -k -O $CRUDAPI_API_JRA_URL 27 | curl -k -O $CRUDAPI_SECURITY_JRA_URL 28 | curl -k -O $CRUDAPI_REST_JRA_URL 29 | curl -k -O $CRUDAPI_WEIXIN_JRA_URL 30 | curl -k -O $CRUDAPI_WINSE_URL 31 | 32 | ls *.gz 33 | ls *.jar 34 | 35 | mvn install:install-file -Dfile=crudapi-core-$CRUDAPI_VERSION.jar -DgroupId=cn.crudapi -DartifactId=crudapi-core -Dversion=$CRUDAPI_VERSION -Dpackaging=jar 36 | mvn install:install-file -Dfile=crudapi-api-$CRUDAPI_VERSION.jar -DgroupId=cn.crudapi -DartifactId=crudapi-api -Dversion=$CRUDAPI_VERSION -Dpackaging=jar 37 | mvn install:install-file -Dfile=crudapi-rest-$CRUDAPI_VERSION.jar -DgroupId=cn.crudapi -DartifactId=crudapi-rest -Dversion=$CRUDAPI_VERSION -Dpackaging=jar 38 | mvn install:install-file -Dfile=crudapi-security-$CRUDAPI_VERSION.jar -DgroupId=cn.crudapi -DartifactId=crudapi-security -Dversion=$CRUDAPI_VERSION -Dpackaging=jar 39 | mvn install:install-file -Dfile=crudapi-weixin-$CRUDAPI_VERSION.jar -DgroupId=cn.crudapi -DartifactId=crudapi-weixin -Dversion=$CRUDAPI_VERSION -Dpackaging=jar 40 | 41 | tar -zxvf WinSW-x64.exe.tar.gz 42 | -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # swagger api 2 | https://demo.crudapi.cn/swagger-ui.html 3 | 4 | # user 5 | superadmin/1234567890 6 | 7 | # login 8 | ## option 1: Cookie 9 | 10 | ### api 11 | ``` 12 | POST https://demo.crudapi.cn/api/auth/login 13 | accept: application/json 14 | content-type: application/x-www-form-urlencoded 15 | username: superadmin 16 | password: 1234567890 17 | ``` 18 | 19 | ## option 2: Jwt token 20 | ### api 21 | ``` 22 | POST https://demo.crudapi.cn/api/auth/jwt/login 23 | accept: application/json 24 | content-type: application/x-www-form-urlencoded 25 | username: superadmin 26 | password: 1234567890 27 | ``` 28 | 29 | ![jwtLogin](./img/auth/jwtLogin.png) 30 | 31 | ### get jwt token 32 | get "token" field form response header: Bearer XXXXX 33 | 34 | ### set jwt token 35 | #### set Bearer Token Type: Bearer XXXXX 36 | Both "Bearer XXXXX" and "XXXX" is valid 37 | ![jwtAuth](./img/auth/jwtAuth.png) 38 | 39 | #### View Authorization 40 | "Authorization" field of request header: Bearer XXXXX 41 | ![jwtAuthorization](./img/auth/jwtAuthorization.png) 42 | 43 | ## option 3: Basic Auth 44 | 45 | ### set Basic auth 46 | #### set Basic Auth Type: superadmin/1234567890 47 | ![basicAuth](./img/auth/basicAuth.png) 48 | 49 | #### View Authorization 50 | "Authorization" field of request header: Basic c3VwZXJhZG1pbjoxMjM0NTY3ODkw 51 | ![basicAuthorization](./img/auth/basicAuthorization.png) 52 | 53 | 54 | 55 | # logout 56 | GET https://demo.crudapi.cn/api/auth/logout 57 | 58 | # create user 59 | POST https://demo.crudapi.cn/api/business/user 60 | ``` 61 | { 62 | "name": "testuser", 63 | "username": "testuser", 64 | "password": "testuser", 65 | "enabled": true, 66 | "accountNonExpired": true, 67 | "accountNonLocked": true, 68 | "credentialsNonExpired": true, 69 | "fileId": null, 70 | "avatar": null, 71 | "roleLines": [{ 72 | "name": "业务数据角色", 73 | "role": { 74 | "id": 20, 75 | "name": "业务数据角色", 76 | }, 77 | "roleId": 20 78 | }] 79 | } 80 | ``` 81 | 82 | # curl example 83 | get sequence by id 84 | ```bash 85 | curl -u 'superadmin:1234567890' -X GET -H 'Content-Type: application/json' 'https://demo.crudapi.cn/api/metadata/sequences/1' 86 | curl -H 'Authorization:Basic c3VwZXJhZG1pbjoxMjM0NTY3ODkw' -X GET -H 'Content-Type: application/json' 'https://demo.crudapi.cn/api/metadata/sequences/1' 87 | ``` 88 | 89 | create sequence 90 | ```bash 91 | curl -u 'superadmin:1234567890' -X POST -H 'Content-Type: application/json' -d '{"currentTime":false,"sequenceType":"STRING","minValue":1,"maxValue":999999999,"nextValue":1,"incrementBy":1,"name":"orderCode","caption":"订单流水号","format":"SO_%9d"}' 'https://demo.crudapi.cn/api/metadata/sequences' 92 | ``` 93 | 94 | import excel data 95 | ```bash 96 | curl -u 'superadmin:1234567890' -F "file=@product.xlsx" "https://demo.crudapi.cn/api/business/product/import" 97 | ``` 98 | -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/config/LoggingAspect.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example.config; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.aspectj.lang.JoinPoint; 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.AfterThrowing; 8 | import org.aspectj.lang.annotation.Around; 9 | import org.aspectj.lang.annotation.Aspect; 10 | import org.aspectj.lang.annotation.Pointcut; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | 15 | /** 16 | * Aspect for logging execution of service and repository Spring components. 17 | * 18 | * By default, it only runs with the "dev" profile. 19 | */ 20 | @Aspect 21 | public class LoggingAspect { 22 | private static final Logger log = LoggerFactory.getLogger(LoggingAspect.class); 23 | 24 | /** 25 | * Pointcut that matches all repositories, services and Web REST endpoints. 26 | */ 27 | @Pointcut("within(@org.springframework.stereotype.Repository *)" 28 | + " || within(@org.springframework.stereotype.Service *)" 29 | + " || within(@org.springframework.web.bind.annotation.RestController *)") 30 | public void springBeanPointcut() { 31 | // Method is empty as this is just a Pointcut, the implementations are in the 32 | // advices. 33 | } 34 | 35 | /** 36 | * Pointcut that matches all Spring beans in the application's main packages. 37 | */ 38 | @Pointcut("within(cn.crudapi.core.repository..*)" 39 | + " || within(cn.crudapi.core.service..*)" 40 | + " || within(cn.crudapi.api.controller..*)") 41 | public void applicationPackagePointcut() { 42 | // Method is empty as this is just a Pointcut, the implementations are in the 43 | // advices. 44 | } 45 | 46 | /** 47 | * Advice that logs methods throwing exceptions. 48 | * 49 | * @param joinPoint 50 | * join point for advice 51 | * @param e 52 | * exception 53 | */ 54 | @AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e") 55 | public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { 56 | log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", 57 | joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), 58 | e.getCause() != null ? e.getCause() : "NULL", e.getMessage(), e); 59 | 60 | } 61 | 62 | /** 63 | * Advice that logs when a method is entered and exited. 64 | * 65 | * @param joinPoint 66 | * join point for advice 67 | * @return result 68 | * @throws Throwable 69 | * throws IllegalArgumentException 70 | */ 71 | @Around("applicationPackagePointcut() && springBeanPointcut()") 72 | public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { 73 | if (log.isDebugEnabled()) { 74 | log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), 75 | joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); 76 | } 77 | try { 78 | Object result = joinPoint.proceed(); 79 | if (log.isDebugEnabled()) { 80 | log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), 81 | joinPoint.getSignature().getName(), result); 82 | } 83 | return result; 84 | } catch (IllegalArgumentException e) { 85 | log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), 86 | joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); 87 | 88 | throw e; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/cn/crudapi/example/Swagger2SpringBoot.java: -------------------------------------------------------------------------------- 1 | package cn.crudapi.example; 2 | 3 | import com.google.common.base.Predicate; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.service.Contact; 9 | import springfox.documentation.spi.DocumentationType; 10 | import springfox.documentation.spring.web.plugins.Docket; 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 | 13 | import static springfox.documentation.builders.PathSelectors.*; 14 | 15 | @Configuration 16 | @EnableSwagger2 17 | public class Swagger2SpringBoot { 18 | @Bean 19 | public Docket caMetadataApi() { 20 | return new Docket(DocumentationType.SWAGGER_2) 21 | .groupName("元数据") 22 | .apiInfo(apiInfo()) 23 | .select() 24 | .paths(caMetadataPaths()) 25 | .build(); 26 | } 27 | 28 | @Bean 29 | public Docket caBusinessApi() { 30 | return new Docket(DocumentationType.SWAGGER_2) 31 | .groupName("业务数据") 32 | .apiInfo(apiInfo()) 33 | .select() 34 | .paths(caBusinessPaths()) 35 | .build(); 36 | } 37 | 38 | @Bean 39 | public Docket fileApi() { 40 | return new Docket(DocumentationType.SWAGGER_2) 41 | .groupName("文件管理") 42 | .apiInfo(apiInfo()) 43 | .select() 44 | .paths(filePaths()) 45 | .build(); 46 | } 47 | 48 | @Bean 49 | public Docket userApi() { 50 | return new Docket(DocumentationType.SWAGGER_2) 51 | .groupName("用户") 52 | .apiInfo(apiInfo()) 53 | .select() 54 | .paths(userPaths()) 55 | .build(); 56 | } 57 | 58 | @Bean 59 | public Docket captchaApi() { 60 | return new Docket(DocumentationType.SWAGGER_2) 61 | .groupName("验证码") 62 | .apiInfo(apiInfo()) 63 | .select() 64 | .paths(captchaPaths()) 65 | .build(); 66 | } 67 | 68 | @Bean 69 | public Docket weixinApi() { 70 | return new Docket(DocumentationType.SWAGGER_2) 71 | .groupName("微信") 72 | .apiInfo(apiInfo()) 73 | .select() 74 | .paths(weixinPaths()) 75 | .build(); 76 | } 77 | 78 | 79 | private Predicate caMetadataPaths() { 80 | return regex("/api/metadata.*"); 81 | } 82 | 83 | private Predicate caBusinessPaths() { 84 | return regex("/api/business.*"); 85 | } 86 | 87 | private Predicate filePaths() { 88 | return regex("/api/file.*"); 89 | } 90 | 91 | private Predicate weixinPaths() { 92 | return regex("/api/weixin.*"); 93 | } 94 | 95 | private Predicate userPaths() { 96 | return regex("/api/user.*"); 97 | } 98 | 99 | 100 | private Predicate captchaPaths() { 101 | return regex("/api/captcha.*"); 102 | } 103 | 104 | private ApiInfo apiInfo() { 105 | return new ApiInfoBuilder() 106 | .title("crudapi增删改查接口零代码产品") 107 | .description("crudapi是crud+api组合,表示增删改查接口,是一款零代码产品。无需编程,通过配置元数据自动生成crud增删改查RESTful API,提供后台UI管理业务数据,支持Java SDK集成或Restful API集成。\n" 108 | + "使用crudapi可以告别枯燥无味的增删改查代码,让您更加专注业务,节约大量成本,从而提高工作效率。crudapi的目标是让处理数据变得更简单,所有人都可以免费使用!") 109 | .termsOfServiceUrl("https://crudapi.cn") 110 | .contact(new Contact("crudapi", "https://crudapi.cn", "admin@crudapi.cn")) 111 | .version("1.0.0") 112 | .build(); 113 | } 114 | } -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # crudapi二次开发demo 2 | 3 | ### LICENSE 4 | [LICENSE](./LICENSE) 5 | 6 | ## 语言 7 | [English](README.md) 8 | 9 | ## GIT地址 10 | 名称 | 类型 | 授权 | GitHub仓库 | Gitee仓库 11 | --- | --- | --- | --- | --- 12 | crudapi-admin-web | Vue Qusar源码 | 开源 | [crudapi-admin-web](https://github.com/crudapi/crudapi-admin-web) | [crudapi-admin-web](https://gitee.com/crudapi/crudapi-admin-web) 13 | crudapi-example| Java集成SDK | 永久免费 | [crudapi-example](https://github.com/crudapi/crudapi-example) | [crudapi-example](https://gitee.com/crudapi/crudapi-example) 14 | 15 | ## Mysql 16 | ### 创建数据库模式crudapi 17 | 18 | ### 配置数据库信息 19 | src/main/resources/application.properties 20 | ```bash 21 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver 22 | spring.datasource.url=jdbc:mysql://localhost:3306/crudapi?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 23 | spring.datasource.username=root 24 | spring.datasource.password=root 25 | 26 | #通过flyway自动创建表 27 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mysql 28 | ``` 29 | 30 | ## Postgresql 31 | ### 新建数据库模式crudapi.public 32 | 33 | ### 配置数据库信息 34 | src/main/resources/application.properties 35 | ```bash 36 | spring.datasource.driverClassName=org.postgresql.Driver 37 | spring.datasource.url=jdbc:postgresql://localhost:5432/crudapi 38 | spring.datasource.username=postgres 39 | spring.datasource.password=postgres 40 | 41 | #通过flyway自动创建表 42 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/postsql 43 | ``` 44 | 45 | ## Oracle 46 | ### 新建数据库模式XEPDB1.crudapi 47 | 48 | ### 配置数据库信息 49 | src/main/resources/application.properties 50 | ```bash 51 | spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 52 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver 53 | spring.datasource.username=crudapi 54 | spring.datasource.password=crudapi 55 | spring.datasource.initialization-mode=always 56 | spring.datasource.schema=classpath:schema.sql 57 | 58 | #通过flyway自动创建表 59 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/oracle 60 | ``` 61 | 62 | ## MS SQL Server 63 | ### 新建数据库模式crudapi.dbo 64 | 65 | ### 配置数据库信息 66 | src/main/resources/application.properties 67 | ```bash 68 | spring.datasource.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=crudapi 69 | spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 70 | spring.datasource.username=sa 71 | spring.datasource.password=Mssql1433 72 | 73 | #通过flyway自动创建表 74 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mssql 75 | ``` 76 | 77 | ### 下载安装依赖包 78 | ```bash 79 | cd lib 80 | ./download.sh 81 | ``` 82 | 83 | ### 编译 84 | ```bash 85 | cd crudapi-example 86 | mvn clean install -Dmaven.test.skip=true 87 | 88 | #阿里云 mirror 89 | mvn clean install -Dmaven.test.skip=true -s settings.xml 90 | ``` 91 | 92 | ### 运行 93 | ```bash 94 | cd crudapi-example 95 | java -jar ./target/crudapi-example-1.6.2.jar 96 | ``` 97 | 98 | ### swagger文档 99 | [http://127.0.0.1:8888/swagger-ui.html](http://127.0.0.1:8888/swagger-ui.html) 100 | 101 | ### crudapi后台管理WEB 102 | [http://127.0.0.1:8888/crudapi/](http://127.0.0.1:8888/crudapi/) 103 | 104 | ### API (二次开发) 105 | [API](./API.md) 106 | 107 | ### crudapi后台管理WEB(二次开发) 108 | #### GitHub仓库 109 | [https://github.com/crudapi/crudapi-admin-web](https://github.com/crudapi/crudapi-admin-web) 110 | 111 | #### Gitee仓库 112 | [https://gitee.com/crudapi/crudapi-admin-web](https://gitee.com/crudapi/crudapi-admin-web) 113 | 114 | #### 修改配置 115 | 修改quasar.conf.js文件中devServer->proxy->target 116 | 117 | ```javascript 118 | devServer: { 119 | https: false, 120 | port: 8080, 121 | open: true, 122 | proxy: { 123 | "/api/*": { 124 | target: "http://127.0.0.1:8888", 125 | changeOrigin: true 126 | } 127 | } 128 | } 129 | ``` 130 | 131 | ## 演示 132 | 演示地址:[https://demo.crudapi.cn/crudapi/](https://demo.crudapi.cn/crudapi/) 133 | 134 | ![table](./img/table.png) 135 | 表单对应不同的对象 136 | 137 | ![relation](./img/relation.png) 138 | 表关系图显示不同对象之间的关系 139 | 140 | ![customer](./img/customer.png) 141 | 业务数据操作 142 | 143 | ## 联系方式 144 | #### 邮箱 145 | admin@crudapi.cn 146 | 147 | #### QQ 148 | 1440737304 149 | 150 | #### QQ群 151 | 632034576 152 | 153 | #### 微信 154 | undefinedneqnull 155 | 156 |
157 | 158 |
159 | 160 | #### 微信群 161 |
162 | 163 |
164 | 165 | 如有任何问题,欢迎咨询和交流! 166 | 167 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #basic 2 | server.port=8888 3 | spring.mvc.view.suffix=.html 4 | spring.mvc.static-path-pattern=/** 5 | spring.resources.static-locations=classpath:/templates/,classpath:/static/,file:${oss.file.path} 6 | spring.mvc.throw-exception-if-no-handler-found=true 7 | spring.resources.add-mappings=true 8 | 9 | #jackson 10 | spring.jackson.time-zone=Asia/Shanghai 11 | spring.jackson.serialization.write-dates-as-timestamps=true 12 | 13 | #log 14 | #logging.level.root=trace 15 | #logging.level.org.springframework.jdbc=trace 16 | logging.file.path=/var/log/cn/crudapi/example 17 | logging.level.cn.crudapi.service.aop.LoggingAspect=info 18 | logging.file.max-history=10 19 | logging.file.max-size=10MB 20 | 21 | #session 22 | spring.session.store-type=JDBC 23 | spring.session.jdbc.cleanup-cron=0 * * * * * 24 | spring.session.timeout=3600 25 | server.servlet.session.timeout=3600 26 | 27 | #user:superadmin/1234567890 28 | spring.security.user.name=superadmin 29 | spring.security.user.password=$2a$10$R9HWotqpXzmLOU0aYlFkquxcs0jq7f1raKHHnsbfT51gM9TF.2q7q 30 | spring.security.user.roles=SUPER_ADMIN 31 | 32 | #compression 33 | server.compression.enabled=true 34 | server.compression.mime-types=application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain 35 | server.compression.min-response-size=1024 36 | server.http2.enabled=true 37 | 38 | #file 39 | spring.servlet.multipart.max-file-size=2048MB 40 | spring.servlet.multipart.max-request-size=2048MB 41 | oss.file.path=/Users/crudapi/opt 42 | oss.upload.domain=http://localhost:8888 43 | oss.upload.path=download 44 | 45 | #job 46 | job.file.cron=0 0 2 * * ? 47 | job.weixin.cron=*/59 * * * * ? 48 | 49 | crudapi.publicPath=crudapi 50 | 51 | #ignoredUrls 52 | secure.ignored.urls[0]=/api/captcha/sms 53 | secure.ignored.urls[1]=/index.html 54 | secure.ignored.urls[2]=/index.html/** 55 | secure.ignored.urls[3]=/ 56 | secure.ignored.urls[4]=/api/business/config 57 | secure.ignored.urls[5]=/**/mapapi 58 | secure.ignored.urls[6]=/**/mapapi/ 59 | secure.ignored.urls[7]=/**/mapapi/** 60 | 61 | #primary 62 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver 63 | spring.datasource.url=jdbc:mysql://localhost:3306/crudapi?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 64 | spring.datasource.username=root 65 | spring.datasource.password=root 66 | 67 | ##postgresql 68 | #spring.datasource.hikari.data-sources[0].postgresql.driverClassName=org.postgresql.Driver 69 | #spring.datasource.hikari.data-sources[0].postgresql.url=jdbc:postgresql://localhost:5432/crudapi 70 | #spring.datasource.hikari.data-sources[0].postgresql.username=postgres 71 | #spring.datasource.hikari.data-sources[0].postgresql.password=postgres 72 | 73 | ##sqlserver 74 | #spring.datasource.hikari.data-sources[1].sqlserver.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 75 | #spring.datasource.hikari.data-sources[1].sqlserver.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=crudapi 76 | #spring.datasource.hikari.data-sources[1].sqlserver.username=sa 77 | #spring.datasource.hikari.data-sources[1].sqlserver.password=Mssql1433 78 | 79 | ###oracle 80 | #spring.datasource.hikari.data-sources[2].oracle.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 81 | #spring.datasource.hikari.data-sources[2].oracle.driverClassName=oracle.jdbc.OracleDriver 82 | #spring.datasource.hikari.data-sources[2].oracle.username=crudapi 83 | #spring.datasource.hikari.data-sources[2].oracle.password=crudapi 84 | #spring.datasource.hikari.data-sources[2].oracle.initialization-mode=always 85 | #spring.datasource.hikari.data-sources[2].oracle.schema=classpath:schema.sql 86 | 87 | ###mysql2 88 | #spring.datasource.hikari.data-sources[3].mysql.driverClassName=com.mysql.cj.jdbc.Driver 89 | #spring.datasource.hikari.data-sources[3].mysql.url=jdbc:mysql://localhost:3306/crudapi2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 90 | #spring.datasource.hikari.data-sources[3].mysql.username=root 91 | #spring.datasource.hikari.data-sources[3].mysql.password=root 92 | 93 | 94 | #primary flyway 95 | spring.flyway.enabled=true 96 | spring.flyway.encoding=UTF-8 97 | spring.flyway.clean-disabled=true 98 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mysql 99 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/postsql 100 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mssql 101 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/oracle 102 | spring.flyway.table=crudapi_flyway_schema_history 103 | spring.flyway.sql-migration-prefix=V 104 | spring.flyway.sql-migration-separator=__ 105 | spring.flyway.sql-migration-suffixes=.sql 106 | spring.flyway.validate-on-migrate=true 107 | spring.flyway.baseline-on-migrate=true 108 | spring.flyway.baseline-version=1.0.0 109 | 110 | -------------------------------------------------------------------------------- /src/main/resources/application-windows.properties: -------------------------------------------------------------------------------- 1 | #basic 2 | server.port=8888 3 | spring.mvc.view.suffix=.html 4 | spring.mvc.static-path-pattern=/** 5 | spring.resources.static-locations=classpath:/templates/,classpath:/static/,file:${oss.file.path} 6 | spring.mvc.throw-exception-if-no-handler-found=true 7 | spring.resources.add-mappings=true 8 | 9 | #jackson 10 | spring.jackson.time-zone=Asia/Shanghai 11 | spring.jackson.serialization.write-dates-as-timestamps=true 12 | 13 | #log 14 | #logging.level.root=trace 15 | #logging.level.org.springframework.jdbc=trace 16 | logging.file.path=D:\\work\\crudapi\\log 17 | logging.level.cn.crudapi.service.aop.LoggingAspect=info 18 | logging.file.max-history=10 19 | logging.file.max-size=10MB 20 | 21 | #session 22 | spring.session.store-type=JDBC 23 | spring.session.jdbc.cleanup-cron=0 * * * * * 24 | spring.session.timeout=3600 25 | server.servlet.session.timeout=3600 26 | 27 | #user:superadmin/1234567890 28 | spring.security.user.name=superadmin 29 | spring.security.user.password=$2a$10$R9HWotqpXzmLOU0aYlFkquxcs0jq7f1raKHHnsbfT51gM9TF.2q7q 30 | spring.security.user.roles=SUPER_ADMIN 31 | 32 | #compression 33 | server.compression.enabled=true 34 | server.compression.mime-types=application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain 35 | server.compression.min-response-size=1024 36 | server.http2.enabled=true 37 | 38 | #file 39 | spring.servlet.multipart.max-file-size=2048MB 40 | spring.servlet.multipart.max-request-size=2048MB 41 | oss.file.path=D:\\work\\crudapi\\oss 42 | oss.upload.domain=http://localhost:8888 43 | oss.upload.path=download 44 | 45 | #job 46 | job.file.cron=0 0 2 * * ? 47 | job.weixin.cron=*/59 * * * * ? 48 | 49 | crudapi.publicPath=crudapi 50 | 51 | #ignoredUrls 52 | secure.ignored.urls[0]=/api/captcha/sms 53 | secure.ignored.urls[1]=/index.html 54 | secure.ignored.urls[2]=/index.html/** 55 | secure.ignored.urls[3]=/ 56 | secure.ignored.urls[4]=/api/business/config 57 | secure.ignored.urls[5]=/**/mapapi 58 | secure.ignored.urls[6]=/**/mapapi/ 59 | secure.ignored.urls[7]=/**/mapapi/** 60 | 61 | #primary 62 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver 63 | spring.datasource.url=jdbc:mysql://localhost:3306/crudapi?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 64 | spring.datasource.username=root 65 | spring.datasource.password=root 66 | 67 | ##postgresql 68 | #spring.datasource.hikari.data-sources[0].postgresql.driverClassName=org.postgresql.Driver 69 | #spring.datasource.hikari.data-sources[0].postgresql.url=jdbc:postgresql://localhost:5432/crudapi 70 | #spring.datasource.hikari.data-sources[0].postgresql.username=postgres 71 | #spring.datasource.hikari.data-sources[0].postgresql.password=postgres 72 | 73 | ##sqlserver 74 | #spring.datasource.hikari.data-sources[1].sqlserver.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 75 | #spring.datasource.hikari.data-sources[1].sqlserver.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=crudapi 76 | #spring.datasource.hikari.data-sources[1].sqlserver.username=sa 77 | #spring.datasource.hikari.data-sources[1].sqlserver.password=Mssql1433 78 | 79 | ###oracle 80 | #spring.datasource.hikari.data-sources[2].oracle.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 81 | #spring.datasource.hikari.data-sources[2].oracle.driverClassName=oracle.jdbc.OracleDriver 82 | #spring.datasource.hikari.data-sources[2].oracle.username=crudapi 83 | #spring.datasource.hikari.data-sources[2].oracle.password=crudapi 84 | #spring.datasource.hikari.data-sources[2].oracle.initialization-mode=always 85 | #spring.datasource.hikari.data-sources[2].oracle.schema=classpath:schema.sql 86 | 87 | ###mysql2 88 | #spring.datasource.hikari.data-sources[3].mysql.driverClassName=com.mysql.cj.jdbc.Driver 89 | #spring.datasource.hikari.data-sources[3].mysql.url=jdbc:mysql://localhost:3306/crudapi2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 90 | #spring.datasource.hikari.data-sources[3].mysql.username=root 91 | #spring.datasource.hikari.data-sources[3].mysql.password=root 92 | 93 | 94 | #primary flyway 95 | spring.flyway.enabled=true 96 | spring.flyway.encoding=UTF-8 97 | spring.flyway.clean-disabled=true 98 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mysql 99 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/postsql 100 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mssql 101 | #spring.flyway.locations=classpath:cn/crudapi/core/db/migration/oracle 102 | spring.flyway.table=crudapi_flyway_schema_history 103 | spring.flyway.sql-migration-prefix=V 104 | spring.flyway.sql-migration-separator=__ 105 | spring.flyway.sql-migration-suffixes=.sql 106 | spring.flyway.validate-on-migrate=true 107 | spring.flyway.baseline-on-migrate=true 108 | spring.flyway.baseline-version=1.0.0 109 | 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Second development demo 2 | 3 | ### LICENSE 4 | [LICENSE](./LICENSE) 5 | 6 | ## Language 7 | [中文](README_CN.md) 8 | 9 | ## GIT URL 10 | Name | Type | License | GitHub| Gitee 11 | --- | --- | --- | --- | --- 12 | crudapi-admin-web | Vue Qusar Code | Open Source | [crudapi-admin-web](https://github.com/crudapi/crudapi-admin-web) | [crudapi-admin-web](https://gitee.com/crudapi/crudapi-admin-web) 13 | crudapi-example| Java SDK | Free Forever | [crudapi-example](https://github.com/crudapi/crudapi-example) | [crudapi-example](https://gitee.com/crudapi/crudapi-example) 14 | 15 | ## Mysql 16 | 17 | ### Create database schema crudapi 18 | 19 | ### Config MySql properties 20 | src/main/resources/application.properties 21 | ```bash 22 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver 23 | spring.datasource.url=jdbc:mysql://localhost:3306/crudapi?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true 24 | spring.datasource.username=root 25 | spring.datasource.password=root 26 | 27 | #auto create table by flyway 28 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mysql 29 | ``` 30 | 31 | ## Postgresql 32 | ### Create database schema crudapi.public 33 | 34 | ### Config Postgresql properties 35 | src/main/resources/application.properties 36 | ```bash 37 | spring.datasource.driverClassName=org.postgresql.Driver 38 | spring.datasource.url=jdbc:postgresql://localhost:5432/crudapi 39 | spring.datasource.username=postgres 40 | spring.datasource.password=postgres 41 | 42 | #auto create table by flyway 43 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/postsql 44 | ``` 45 | 46 | ## Oracle 47 | ### Create database schema XEPDB1.crudapi 48 | 49 | ### Config Postgresql properties 50 | src/main/resources/application.properties 51 | ```bash 52 | spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 53 | spring.datasource.driverClassName=oracle.jdbc.OracleDriver 54 | spring.datasource.username=crudapi 55 | spring.datasource.password=crudapi 56 | spring.datasource.initialization-mode=always 57 | spring.datasource.schema=classpath:schema.sql 58 | 59 | #auto create table by flyway 60 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/oracle 61 | ``` 62 | 63 | ## MS SQL Server 64 | ### Create database schema crudapi.dbo 65 | 66 | ### Config Postgresql properties 67 | src/main/resources/application.properties 68 | ```bash 69 | spring.datasource.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=crudapi 70 | spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 71 | spring.datasource.username=sa 72 | spring.datasource.password=Mssql1433 73 | 74 | #auto create table by flyway 75 | spring.flyway.locations=classpath:cn/crudapi/core/db/migration/mssql 76 | ``` 77 | 78 | 79 | ### download and install dependency package 80 | ```bash 81 | cd lib 82 | ./download.sh 83 | ``` 84 | 85 | ### Build 86 | ```bash 87 | cd crudapi-example 88 | mvn clean install -Dmaven.test.skip=true 89 | 90 | #aliyun mirror 91 | mvn clean install -Dmaven.test.skip=true -s settings.xml 92 | ``` 93 | 94 | ### Run 95 | ```bash 96 | cd crudapi-example 97 | java -jar ./target/crudapi-example-1.6.2.jar 98 | ``` 99 | 100 | ### Swagger 101 | [http://127.0.0.1:8888/swagger-ui.html](http://127.0.0.1:8888/swagger-ui.html) 102 | 103 | ### Crudapi Admin Web 104 | [http://127.0.0.1:8888/crudapi/](http://127.0.0.1:8888/crudapi/) 105 | User and password 106 | ``` 107 | superadmin 108 | 1234567890 109 | ``` 110 | 111 | ### API (developer) 112 | [API](./API.md) 113 | 114 | ### Crudapi Admin Web (developer) 115 | #### GitHub repo 116 | [https://github.com/crudapi/crudapi-admin-web](https://github.com/crudapi/crudapi-admin-web) 117 | 118 | #### Gitee repo 119 | [https://gitee.com/crudapi/crudapi-admin-web](https://gitee.com/crudapi/crudapi-admin-web) 120 | 121 | #### Config 122 | update file quasar.conf.js, set devServer->proxy->target 123 | quasar.conf.js 124 | ```javascript 125 | devServer: { 126 | https: false, 127 | port: 8080, 128 | open: true, 129 | proxy: { 130 | "/api/*": { 131 | target: "http://127.0.0.1:8888", 132 | changeOrigin: true 133 | } 134 | } 135 | } 136 | ``` 137 | 138 | ## Demo 139 | Demo url:[https://demo.crudapi.cn/crudapi/](https://demo.crudapi.cn/crudapi/) 140 | 141 | ![table](./img/table.png) 142 | Metadata table 143 | 144 | ![table](./img/relation.png) 145 | Table relation 146 | 147 | ![customer](./img/customer.png) 148 | Bussiness Data 149 | 150 | ## Contact 151 | #### Email 152 | admin@crudapi.cn 153 | 154 | #### QQ 155 | 1440737304 156 | 157 | #### QQQun 158 | 632034576 159 | 160 | #### Weixin 161 | undefinedneqnull 162 | 163 |
164 | 165 |
166 | 167 | #### WeixinQun 168 |
169 | 170 |
171 | 172 | If you have any questions, please contact us! 173 | 174 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | cn.crudapi 6 | crudapi-example 7 | 1.6.2 8 | crudapi-example 9 | Demo project for crudapi 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 2.2.6.RELEASE 14 | 15 | 16 | 17 | UTF-8 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-security 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-aop 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-jdbc 41 | 42 | 43 | mysql 44 | mysql-connector-java 45 | runtime 46 | 47 | 48 | org.postgresql 49 | postgresql 50 | runtime 51 | 52 | 53 | com.microsoft.sqlserver 54 | mssql-jdbc 55 | runtime 56 | 57 | 58 | com.oracle.database.jdbc 59 | ojdbc8 60 | 21.5.0.0 61 | runtime 62 | 63 | 64 | commons-codec 65 | commons-codec 66 | 67 | 68 | commons-io 69 | commons-io 70 | 2.4 71 | 72 | 73 | org.apache.commons 74 | commons-lang3 75 | 76 | 77 | org.apache.commons 78 | commons-collections4 79 | 4.4 80 | 81 | 82 | org.apache.commons 83 | commons-csv 84 | 1.8 85 | 86 | 87 | org.springframework.session 88 | spring-session-jdbc 89 | 90 | 91 | com.squareup.okhttp3 92 | okhttp 93 | 94 | 95 | org.springframework.security 96 | spring-security-jwt 97 | 1.1.1.RELEASE 98 | 99 | 100 | io.jsonwebtoken 101 | jjwt 102 | 0.9.1 103 | 104 | 105 | cn.hutool 106 | hutool-all 107 | 5.5.6 108 | 109 | 110 | com.github.penggle 111 | kaptcha 112 | 2.3.2 113 | 114 | 115 | org.jadira.usertype 116 | usertype.core 117 | 7.0.0.CR1 118 | 119 | 120 | joda-time 121 | joda-time 122 | 123 | 124 | com.fasterxml.jackson.datatype 125 | jackson-datatype-joda 126 | 127 | 128 | io.springfox 129 | springfox-swagger2 130 | 2.9.2 131 | 132 | 133 | io.springfox 134 | springfox-swagger-ui 135 | 2.9.2 136 | 137 | 138 | org.apache.poi 139 | poi 140 | 5.0.0 141 | 142 | 143 | org.apache.poi 144 | poi-ooxml 145 | 5.0.0 146 | 147 | 148 | org.freemarker 149 | freemarker 150 | 2.3.31 151 | 152 | 153 | org.flywaydb 154 | flyway-core 155 | 156 | 157 | cn.crudapi 158 | crudapi-core 159 | 1.6.2 160 | 161 | 162 | cn.crudapi 163 | crudapi-api 164 | 1.6.2 165 | 166 | 167 | cn.crudapi 168 | crudapi-security 169 | 1.6.2 170 | 171 | 172 | cn.crudapi 173 | crudapi-rest 174 | 1.6.2 175 | 176 | 177 | cn.crudapi 178 | crudapi-weixin 179 | 1.6.2 180 | 181 | 182 | 183 | 184 | 185 | org.springframework.boot 186 | spring-boot-maven-plugin 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------