调整
This commit is contained in:
parent
80bd441ee6
commit
088dc1bf09
11
pom.xml
11
pom.xml
@ -258,8 +258,19 @@
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<!-- jinjia2模板文件 -->
|
||||
<include>**/**/*.j2</include>
|
||||
<!-- Mapper文件、XML转化文件 -->
|
||||
<include>**/*.xml</include>
|
||||
<!-- 启动配置文件 -->
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.yaml</include>
|
||||
<include>**/*.properties</include>
|
||||
<!-- 静态资源 -->
|
||||
<include>**/*.ico</include>
|
||||
<include>**/*.css</include>
|
||||
<include>**/*.js</include>
|
||||
<include>**/*.html</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.example.demo.common.config.springdoc;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OpenApiStarterOutput implements CommandLineRunner {
|
||||
|
||||
private final ServerProperties serverProperties;
|
||||
private final Environment environment;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
String pathInYaml = "server.servlet.context-path";
|
||||
String portInYaml = "server.port";
|
||||
|
||||
String port = environment.getProperty(portInYaml, "8080");
|
||||
String path = environment.getProperty(pathInYaml, "");
|
||||
|
||||
// 获取当前激活的环境(如dev、test、prod)
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
String activeProfile = activeProfiles.length > 0 ? activeProfiles[0] : "default";
|
||||
|
||||
// 输出包含环境信息和动态端口的API文档地址
|
||||
System.out.printf("当前环境: %s,API文档地址: http://localhost:%s%s/doc.html#/%n",
|
||||
activeProfile, port, path);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.example.demo.common.config.web;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// ignore
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
# 服务器配置
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /parser
|
||||
port: 19290
|
||||
# servlet:
|
||||
# context-path: /parser
|
||||
|
||||
# 通用 log 输出配置
|
||||
logging:
|
||||
@ -21,6 +21,8 @@ spring:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
profiles:
|
||||
# active: orm,h2,sqlite,springdoc
|
||||
# active: ${spring.profiles.group.dev}
|
||||
active: dev
|
||||
group:
|
||||
dev: orm,h2,sqlite,springdoc
|
||||
|
@ -44,7 +44,7 @@ public class ApplicationTest__04 {
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
@DisplayName("testOne - 多层级XML(草稿04) - 【已验证】")
|
||||
@DisplayName("testOne - 多层级XML并写入文件(草稿04) - 【已验证】")
|
||||
public void testOne() {
|
||||
|
||||
List<String> dataList = new ArrayList<>() {{
|
||||
@ -57,6 +57,7 @@ public class ApplicationTest__04 {
|
||||
String inputTemplateData = prefix + "default.json";
|
||||
String inputData = prefix + dataList.get(new Random().nextInt(dataList.size()));
|
||||
String processJSONFile = "output-transformed-cg-003__04.json";
|
||||
String processTextFile = "output-transformed-cg-003__04.txt";
|
||||
|
||||
// Step.1
|
||||
try {
|
||||
@ -92,8 +93,9 @@ public class ApplicationTest__04 {
|
||||
// Step.3
|
||||
Map demoData = JSON.parseObject(result, Map.class);
|
||||
System.out.println("=== 测试动态模板 ===");
|
||||
String result1 = EnhancedTemplateGenerator.generateCodeWithFormat(demoData, "generator/jinjia2/dynamic-template.j2");
|
||||
System.out.println(result1);
|
||||
String content = EnhancedTemplateGenerator.generateCodeWithFormat(demoData, "generator/jinjia2/dynamic-template.j2");
|
||||
System.out.println(content);
|
||||
Files.writeString(Path.of(processTextFile), content, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user