Compare commits

..

45 Commits

Author SHA1 Message Date
38b3cbb4c5 Update template/pom.xml 2025-01-11 08:41:35 +08:00
a0905efaa2 Update template/pom.xml 2025-01-09 14:42:11 +08:00
0d8485e11a Update template/.gitignore 2024-12-31 18:38:09 +08:00
ycl
f9039b7e85 更新 template/entrance/web/src/main/resources/application.properties 2024-12-26 10:08:22 +08:00
835fc333df Update template/Dockerfile 2024-12-05 10:10:17 +08:00
74c996a287 add codestyle 2024-09-30 10:48:53 +08:00
oyo
7ba3330b86 增加agent 2024-09-14 14:46:39 +08:00
oyo
e7873858a7 增加agent 2024-09-14 12:06:28 +08:00
oyo
5b7e07be34 增加agent 2024-09-14 11:10:35 +08:00
041d0116df Update template/.gitignore 2024-09-03 18:45:22 +08:00
ycl
2fad43dbfd 更新 template/common/pom.xml 2024-09-03 10:18:30 +08:00
oyo
e5fd517612 ResponseJsonMethodReturnValueHandler 2024-08-29 17:08:52 +08:00
5e1775eb61 更新 template/pom.xml 2024-08-22 17:21:08 +08:00
cafd3e500a Update template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java 2024-08-21 12:59:41 +08:00
b6fb55800e 更新 template/pom.xml 2024-08-19 10:59:50 +08:00
d7dfeb3550 更新 template/common/pom.xml 2024-08-18 17:53:38 +08:00
4b8b2f19ff 更新 template/entrance/web/src/main/resources/application-local.properties 2024-08-18 17:08:25 +08:00
a616208ccf 更新 template/entrance/web/pom.xml 2024-08-18 16:35:38 +08:00
ef9d2cf341 更新 template/common/pom.xml 2024-08-18 16:33:14 +08:00
661b1f2a7a 更新 template/entrance/web/pom.xml 2024-08-16 19:23:24 +08:00
9fda09fd8d 更新 template/entrance/web/src/main/resources/application.properties 2024-08-16 19:08:21 +08:00
1e8924e799 更新 template/pom.xml 2024-08-16 19:05:48 +08:00
db4cc3ec27 Update template/entrance/pom.xml 2024-08-13 17:07:51 +08:00
d9110e30ae Update template/pom.xml 2024-08-13 17:07:12 +08:00
6eb819501d Update template/.gitignore 2024-08-13 09:32:20 +08:00
342ea37e12 Delete template/.gitattributes 2024-08-13 09:31:45 +08:00
98d9d0dd2e Update template/.gitattributes 2024-08-09 08:15:35 +08:00
b6df6baa11 Add template/.gitattributes 2024-08-08 21:53:26 +08:00
45242e42bb Update template/.gitignore 2024-08-08 19:10:36 +08:00
36b5fa7ba3 Update template/entrance/web/src/main/resources/application-local.properties 2024-08-07 17:29:48 +08:00
ycl
2dcf7a1f25 更新 template/entrance/web/src/main/resources/#application-local.properties 2024-08-07 16:55:54 +08:00
ycl
45156d8040 删除 template/entrance/web/src/test/java/com/hande/handeTest/entrance/web/AppApplicationTest.java 2024-08-07 16:18:50 +08:00
e03186c495 Update template/entrance/pom.xml 2024-08-07 16:17:22 +08:00
2762838d2c Update template/Dockerfile 2024-08-07 14:30:38 +08:00
ycl
f6d1a1ddee 更新 template/entrance/web/src/main/resources/application-remote.properties 2024-08-07 11:32:03 +08:00
ycl
65365ec4f3 更新 template/entrance/web/src/main/resources/application-online.properties 2024-08-07 11:29:06 +08:00
ycl
240b7c29ff 更新 template/entrance/web/src/main/resources/#application-local.properties 2024-08-07 11:28:24 +08:00
ycl
c832d116a5 更新 template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java 2024-08-07 11:22:32 +08:00
5f6bacf1db 更新 template/entrance/web/src/main/resources/application-online.properties
注释es配置
2024-08-07 10:39:30 +08:00
7a547471f7 更新 template/entrance/web/src/main/resources/application-remote.properties
注释es配置
2024-08-07 10:38:10 +08:00
ycl
7947e101ef 更新 template/entrance/web/src/main/resources/#application-local.properties 2024-08-07 10:33:48 +08:00
ycl
45b7d9f6a2 更新 template/common/src/main/java/{{.packagePath}}/common/elasticsearch/EsService.java 2024-08-07 10:32:39 +08:00
ycl
e1629f2ccb 更新 template/common/src/main/java/{{.packagePath}}/common/elasticsearch/EsConfiguration.java 2024-08-07 10:31:49 +08:00
e9c7377e84 Merge branch 'main' of https://code.byteawake.com/templates/libawall-springboot-template 2024-08-06 19:34:50 +08:00
7131c56e31 init 2024-08-06 19:34:30 +08:00
23 changed files with 928 additions and 564 deletions

8
template/.gitignore vendored
View File

@@ -10,9 +10,10 @@ classes/
## idea
*.iml
.idea/**
HELP.md
.idea/*
!.idea/codeStyles/
!.idea/dataSources.xml
HELP.md
## vscode
.vscode/
@@ -29,5 +30,6 @@ logs/
## vs
.vs
modules/**
!modules/.gitkeep
.gitattributes
.toco/config.local.yml

7
template/.idea/codeStyles/Project.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
</JavaCodeStyleSettings>
</code_scheme>
</component>

View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@@ -1,13 +1,12 @@
# syntax=registry.cn-hangzhou.aliyuncs.com/imageacc/dockerfile:experimental
FROM registry.cn-hangzhou.aliyuncs.com/zeroware/javaapp-builder:latest as builder
FROM maven:3.8.8 AS builder
WORKDIR source
COPY ./ ./
ARG JAR_FILE=entrance/web/target/*.jar
RUN --mount=type=cache,target=/root/.m2/repository,rw --mount=type=tmpfs,target=/root/.m2/repository/{{ .groupId | replace "." "/" }} mvnd clean package -Dmaven.test.skip=true
RUN mvn clean package -Dmaven.test.skip=true
RUN cp ${JAR_FILE} app.jar
RUN java -Djarmode=layertools -jar ./app.jar extract
FROM registry.cn-hangzhou.aliyuncs.com/zeroware/openjdk-17:latest
FROM openjdk:11.0.14
WORKDIR /application
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone

View File

@@ -8,17 +8,14 @@
<version>{{ .version }}</version>
</parent>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-common</artifactId>
<version>{{ .version }}</version>
<properties>
<elasticsearch.version>7.3.1</elasticsearch.version>
</properties>
<dependencies>
<dependency>
<groupId>com.vs</groupId>
<artifactId>dist</artifactId>
<groupId>com.toco</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
@@ -41,40 +38,29 @@
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-basidc-common</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.9.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs.common.util</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -25,8 +25,11 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Objects;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Configuration
@ConditionalOnProperty(name = "essql.hosts")
public class EsConfiguration {
private static int connectTimeOut = 1000; // 连接超时时间
private static int socketTimeOut = 30000; // 连接超时时间

View File

@@ -52,6 +52,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import {{ .package }}.common.utils.JsonUtils;
@@ -60,6 +62,7 @@ import {{ .package }}.common.utils.JsonUtils;
*/
@Component
@ConditionalOnProperty(name = "essql.hosts")
public class EsService {
@Resource

View File

@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>{{ .artifactId }}-entrance</artifactId>
<version>{{ .version }}</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-common</artifactId>
<version>{{ .version }}</version>
</dependency>
</dependencies>
<modules>
<module>mq</module>
<module>web</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}</artifactId>
<version>{{ .version }}</version>
</parent>
<artifactId>{{ .artifactId }}-entrance</artifactId>
<version>{{ .version }}</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-common</artifactId>
<version>{{ .version }}</version>
</dependency>
</dependencies>
<modules>
<module>mq</module>
<module>web</module>
</modules>
</project>

View File

@@ -12,11 +12,7 @@
<dependencies>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-springboot-web-starter</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<groupId>com.toco</groupId>
<artifactId>vs-sqlmapper-spring</artifactId>
</dependency>
<dependency>
@@ -27,28 +23,18 @@
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-mock-web</artifactId>
<version>${vs.mock.spring}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-agent</artifactId>
<version>${vs.debug.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-plugin</artifactId>
<version>${vs.debug.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -5,6 +5,7 @@ import com.vs.sqlmapper.spring.DataSourceConfig;
import com.vs.sqlmapper.spring.scan.VSDaoBeanScan;
import com.vs.mock.config.EnableVSMockConfiguration;
import com.vs.sqlmapper.spring.express.EnableVSMockExpress;
import com.vs.agent.TocoAgentInitializer;
import com.vs.debug.stack.agent.LogStackContextInvokeRecorder;
import com.vs.debug.stack.agent.MethodVisitorHandlerFilter;
@@ -17,15 +18,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
/**
* 应用入口
*
* @author byteawake
* @date 2021/5/11 下午5:30
*/
@SpringBootApplication(scanBasePackages = {"com.hande", "com.vs", "com.hande.index_sync"})
@VSDaoBeanScan(basePackages = {"com.vs","com.hande"})
@SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"})
@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"})
@Import(DataSourceConfig.class)
@EnableVSReplayConfiguration
@EnableVSMockConfiguration
@@ -44,6 +38,8 @@ public class AppApplication{
}
public static void main(String[] args) {
SpringApplication.run(AppApplication.class,args);
SpringApplication application = new SpringApplication(AppApplication.class);
application.addInitializers(new TocoAgentInitializer());
application.run(args);
}
}

View File

@@ -0,0 +1,53 @@
package {{ .package }}.entrance.web.response;
import com.libawall.framework.core.base.result.ResultDTO;
import com.vs.common.util.rpc.pub.PublicInterface;
import com.vs.ox.common.utils.ObjectMapperFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.method.support.ModelAndViewContainer;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Collections;
/**
* 处理 Controller 里的返回值,从 Object 包装为 ResultDTO 类型
*/
@Slf4j
public class ResponseJsonMethodReturnValueHandler implements HandlerMethodReturnValueHandler, InitializingBean {
private HttpMessageConverter messageConverter;
public ResponseJsonMethodReturnValueHandler() {
}
public void afterPropertiesSet() {
if (this.messageConverter == null) {
this.messageConverter = new MappingJackson2HttpMessageConverter(ObjectMapperFactory.getDefaultObjectMapper());
}
}
public boolean supportsReturnType(MethodParameter returnType) {
return true;
}
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
Method method = returnType.getMethod();
//目前只处理自动生成接口
PublicInterface annotation = method.getAnnotation(PublicInterface.class);
if (annotation != null) {
mavContainer.setRequestHandled(true);
Object result = returnValue == null ? ResultDTO.ok(Collections.emptyMap()) : ResultDTO.ok((returnValue));
ServletServerHttpResponse response = new ServletServerHttpResponse(webRequest.getNativeResponse(HttpServletResponse.class));
this.messageConverter.write(result, new MediaType(MediaType.APPLICATION_JSON, Collections.singletonMap("charset", "utf-8")), response);
}
}
}

View File

@@ -0,0 +1,69 @@
package {{ .package }}.entrance.web.response;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.annotation.MapMethodProcessor;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Configuration
public class ResponseJsonWebMvcConfiguration implements ApplicationContextAware, WebMvcConfigurer {
private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
private ApplicationContext applicationContext;
void init() {
List<HandlerMethodReturnValueHandler> returnValueHandlers = this.requestMappingHandlerAdapter.getReturnValueHandlers();
Iterator<HandlerMethodReturnValueHandler> iterator = returnValueHandlers.iterator();
List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>();
while (iterator.hasNext()) {
HandlerMethodReturnValueHandler next = iterator.next();
//在controller中直接返回map不被默认的MapMethodProcessor拦截
if (next instanceof MapMethodProcessor ||
//在controller中直接返回String不被默认的ViewNameMethodReturnValueHandler拦截
next instanceof ViewNameMethodReturnValueHandler) {
} else {
newProcessors.add(next);
}
}
this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors);
}
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
ResponseJsonMethodReturnValueHandler responseJsonMethodReturnValueHandler = new ResponseJsonMethodReturnValueHandler();
responseJsonMethodReturnValueHandler.afterPropertiesSet();
returnValueHandlers.add(responseJsonMethodReturnValueHandler);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Bean
ServletContextListener listener1() {
return new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent sce) {
requestMappingHandlerAdapter = applicationContext.getBean(RequestMappingHandlerAdapter.class);
init();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
};
}
}

View File

@@ -5,9 +5,10 @@ server.forward-headers-strategy=framework
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package=com.hande
base.package={{.groupId}}
mock.enabled=true
# datasource
spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:hande_test_user}
spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
@@ -45,11 +46,11 @@ spring.main.allow-circular-references=true
spring.login.security.csrf=false
#elasticsearch
essql.hosts=${OPENSEARCH_HOST:10.0.2.221,10.0.2.222,10.0.2.223}
essql.port=9200
essql.username=${OPENSEARCH_USER:admin}
essql.password=${OPENSEARCH_PASSWORD:dnZkaNVK}
essql.scheme=${OPENSEARCH_SCHEME:https}
#essql.hosts=${OPENSEARCH_HOST:10.0.2.221,10.0.2.222,10.0.2.223}
#essql.port=9200
#essql.username=${OPENSEARCH_USER:admin}
#essql.password=${OPENSEARCH_PASSWORD:dnZkaNVK}
#essql.scheme=${OPENSEARCH_SCHEME:https}
#get user config
get_user_uri={}

View File

@@ -5,7 +5,7 @@ server.forward-headers-strategy=framework
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package=com.hande
base.package={{.groupId}}
# datasource
spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:hande_test_user}
@@ -30,11 +30,11 @@ rocketmq.tag=*
rocketmq.producer.group=PID_handeTest
#elasticsearch
essql.hosts=${OPENSEARCH_HOST}
essql.port=9200
essql.username=${OPENSEARCH_USER:admin}
essql.password=${OPENSEARCH_PASSWORD:admin}
essql.scheme=${OPENSEARCH_SCHEME:https}
#essql.hosts=${OPENSEARCH_HOST}
#essql.port=9200
#essql.username=${OPENSEARCH_USER:admin}
#essql.password=${OPENSEARCH_PASSWORD:admin}
#essql.scheme=${OPENSEARCH_SCHEME:https}
#get user config
get_user_uri={}

View File

@@ -5,7 +5,7 @@ server.forward-headers-strategy=framework
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package=com.hande
base.package={{.groupId}}
# datasource
spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:hande_test_user}
@@ -30,11 +30,11 @@ rocketmq.tag=*
rocketmq.producer.group=PID_handeTest
#elasticsearch
essql.hosts=${OPENSEARCH_HOST:10.0.2.221,10.0.2.222,10.0.2.223}
essql.port=9200
essql.username=${OPENSEARCH_USER:admin}
essql.password=${OPENSEARCH_PASSWORD:dnZkaNVK}
essql.scheme=${OPENSEARCH_SCHEME:https}
#essql.hosts=${OPENSEARCH_HOST:10.0.2.221,10.0.2.222,10.0.2.223}
#essql.port=9200
#essql.username=${OPENSEARCH_USER:admin}
#essql.password=${OPENSEARCH_PASSWORD:dnZkaNVK}
#essql.scheme=${OPENSEARCH_SCHEME:https}
#get user config
get_user_uri={}

View File

@@ -4,3 +4,9 @@ spring.main.allow-bean-definition-overriding=true
project_id=${projectId}
project_name=handeTest
check=true
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
com.toco.agent.attach=true

View File

@@ -1,14 +0,0 @@
package {{ .package }}.entrance.web;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AppApplicationTest {
@Test
public void contextLoads() {
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
id=8347572c-b33f-4888-b1bf-cc9149fff6f7
name=hande_test
version=1.0.0
id={{ .projectId }}
name={{ .projectName | replace "-" "_" }}
version={{ .vsVersion }}