Skip to content

Commit fac5880

Browse files
committed
springboot-hello init
1 parent 0a1dc6d commit fac5880

File tree

7 files changed

+138
-21
lines changed

7 files changed

+138
-21
lines changed

springboot-hello/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
HELP.md
2+
/target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
/build/
27+
28+
### VS Code ###
29+
.vscode/

springboot-hello/pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.1.3.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>cn.tellsea</groupId>
12+
<artifactId>springboot-hello</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>springboot-hello</name>
15+
<description>Demo project for Spring Boot</description>
16+
17+
<properties>
18+
<java.version>1.8</java.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-test</artifactId>
30+
<scope>test</scope>
31+
</dependency>
32+
</dependencies>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-maven-plugin</artifactId>
39+
</plugin>
40+
</plugins>
41+
</build>
42+
43+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.tellsea;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringbootHelloApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringbootHelloApplication.class, args);
11+
}
12+
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cn.tellsea.web;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.bind.annotation.ResponseBody;
6+
7+
@Controller
8+
public class HelloController {
9+
10+
@RequestMapping("/hello")
11+
@ResponseBody
12+
public String hello() {
13+
return "Hello SpringBoot!";
14+
}
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.tellsea;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class SpringbootHelloApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

springboot-thymeleaf-static/src/main/java/cn/tellsea/service/impl/ThymeleafServiceImpl.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ public Map<String, Object> loadModel(Long id) {
3030
return map;
3131
}
3232

33-
/**
34-
* 创建html页面
35-
*
36-
* @param spuId
37-
* @throws Exception
38-
*/
39-
public void createHtml(Long spuId) {
40-
// 上下文
41-
Context context = new Context();
42-
context.setVariables(loadModel(spuId));
43-
// 输出流
44-
File dest = new File(destPath, spuId + ".html");
45-
if (dest.exists()) {
46-
dest.delete();
47-
}
48-
try (PrintWriter writer = new PrintWriter(dest, "UTF-8")) {
49-
// 生成html
50-
templateEngine.process("id", context, writer);
51-
} catch (Exception e) {
52-
log.error("[静态页服务]:生成静态页异常", e);
33+
/**
34+
* 创建html页面
35+
*
36+
* @param spuId
37+
* @throws Exception
38+
*/
39+
public void createHtml(Long spuId) {
40+
// 上下文
41+
Context context = new Context();
42+
context.setVariables(loadModel(spuId));
43+
// 输出流
44+
File dest = new File(destPath, spuId + ".html");
45+
if (dest.exists()) {
46+
dest.delete();
47+
}
48+
try (PrintWriter writer = new PrintWriter(dest, "UTF-8")) {
49+
// 生成html
50+
templateEngine.process("id", context, writer);
51+
} catch (Exception e) {
52+
log.error("[静态页服务]:生成静态页异常", e);
53+
}
5354
}
54-
}
5555

5656
public void deleteHtml(Long id) {
5757
// 输出流

0 commit comments

Comments
 (0)