Skip to content

Commit

Permalink
Add: springboot demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Q01 committed Jun 21, 2021
1 parent 5236172 commit 1465422
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 0 deletions.
7 changes: 7 additions & 0 deletions springboot-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.class
*.log
*.ctxt
.mtj.tmp/
.idea
*.iml
target
15 changes: 15 additions & 0 deletions springboot-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Webhook5
FROM maven:3.8.1-openjdk-8-slim
ADD pom.xml /tmp/build/
WORKDIR /tmp/build
RUN mvn dependency:resolve

ADD src /tmp/build/src
RUN mvn -DskipTests=true package && \
mv target/*.jar /app.jar && \
cd / && rm -rf /tmp/build

FROM openjdk:8u292-jre-slim
COPY --from=0 /app.jar .
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
170 changes: 170 additions & 0 deletions springboot-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?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>
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>aliyun-central</id>
<url>https://maven.aliyun.com/repository/central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-central</id>
<url>https://maven.aliyun.com/repository/central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-google</id>
<url>https://maven.aliyun.com/repository/google</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-spring-plugin</id>
<url>https://maven.aliyun.com/repository/spring-plugin</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-public</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-releases</id>
<url>https://maven.aliyun.com/repository/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin-snapshots</id>
<url>https://maven.aliyun.com/repository/snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>

<groupId>com.xiicloud.demo.spring</groupId>
<artifactId>springboot-demo</artifactId>
<version>v1.0.0</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springboot.version>1.5.6.RELEASE</springboot.version>
<java.version>1.8</java.version>
</properties>

<name>springboot-demo</name>
<url>http://maven.apache.org</url>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${springboot.version}</version>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
13 changes: 13 additions & 0 deletions springboot-demo/src/main/java/com/xiicloud/demo/spring/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.xiicloud.demo.spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"com.xiicloud"})
public class Main {

public static void main(String[] args) {
SpringApplication.run(Main.class , args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.xiicloud.demo.spring.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource(locations = {"classpath:/spring/applicationContext*.xml"})
public class Config {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.xiicloud.demo.spring.controller;

import com.xiicloud.demo.spring.entity.Guest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/")
public class IndexController {

@Autowired
private Guest guest;

@GetMapping("/")
public String index (ModelMap model) {

model.addAttribute("name" , guest.getName());
model.addAttribute("sex" , guest.getSex());
return "index";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.xiicloud.demo.spring.entity;

import org.springframework.stereotype.Component;

@Component
public class Guest {

private String name;

private String sex;

public void setSex(String sex) {
this.sex = sex;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSex() {
return sex;
}

public Guest(String sex) {
this.sex = sex;
}
}
17 changes: 17 additions & 0 deletions springboot-demo/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
spring:
devtools:
restart:
exclude: public/**
enabled: true
thymeleaf:
suffix: .html
mode: HTML5
encoding: UTF-8
content-type: text/html; charset=utf-8
cache: false

mybatis:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath*:mappers/*Mapper.xml

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">

<context:annotation-config />

<context:component-scan base-package="com.xiicloud.SpringBootMavenArchetype" />

<beans>

<bean name="guest" class="com.xiicloud.demo.spring.entity.Guest">
<constructor-arg name="sex" type="java.lang.String" value="Boy"></constructor-arg>
<property name="name" value="Vistor"></property>
</bean>


</beans>

</beans>

Empty file.
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions springboot-demo/src/main/resources/templates/common/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="footer">
<div class="layui-footer footer footer-demo">
<div class="layui-main">
<p>
<a th:href="@{/}">
Copyright 2021 XiiCloud v1.0 All Rights Reserved.
</a>
</p>
</div>
</div>
<th:block th:include="common/script::script"></th:block>
</div>
</body>
</html>
15 changes: 15 additions & 0 deletions springboot-demo/src/main/resources/templates/common/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="header(title)">
<meta charset="utf-8" />
<title th="${title}">XiiCloud CI测试</title>
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" th:href="@{/css/main.css}" media="all" />
</head>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="script">
<script th:src="@{/js/main.js}"></script>
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions springboot-demo/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header::header(title='XiiCloud CI测试')"></head>
<body>

<div th:text="'Welcome ' + ${name} + ', are you a ' + ${sex} + '?'"></div>

<th:block th:include="common/footer::footer"></th:block>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.xiicloud.demo.spring;

0 comments on commit 1465422

Please sign in to comment.