springboot用法和与各种框架、组件等结合使用,包括springboot的注解分析、路径分析、取得内置对象、项目打包、配置环境属性、读取资源文件、Bean配置、模板渲染、基于yml的多profile配置、基于properties的多profile、添加数据验证、配置错误页、全局异常处理、配置Tomcat运行、配置https访问路径、信息显示、内置对象、显示对象信息、文件上传、使用文件服务器、拦截器、配置druid数据库连接池、整合MyBatis框架、事务控制、Druid监控、整合ActiveMQ、整合RabbitMQ、整合kafka、邮件发送、定时调度、Actuator监控、整合Redis数据库、整合Restfui框架、整合Shiro
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/view">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>microboot-mybatis</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.springframework.ide.eclipse.core.springnature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/main/view=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
@@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="cloudfoundry.standalone.app" version="1.0"/>
|
||||
</faceted-project>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.mldn</groupId>
|
||||
<artifactId>microboot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>microboot-mybatis</artifactId>
|
||||
<name>microboot-mybatis</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jetty</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>springloaded</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.mldn.microboot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication // 启动SpringBoot程序,而后自带子包扫描
|
||||
@EnableTransactionManagement
|
||||
public class StartSpringBootMain {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(StartSpringBootMain.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.mldn.microboot.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
|
||||
@Configuration
|
||||
public class DruidConfig {
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServlet() { // 主要实现WEB监控的配置处理
|
||||
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(
|
||||
new StatViewServlet(), "/druid/*"); // 现在要进行druid监控的配置处理操作
|
||||
servletRegistrationBean.addInitParameter("allow",
|
||||
"127.0.0.1,192.168.28.159"); // 白名单
|
||||
servletRegistrationBean.addInitParameter("deny", "192.168.28.200"); // 黑名单
|
||||
servletRegistrationBean.addInitParameter("loginUsername", "mldnjava"); // 用户名
|
||||
servletRegistrationBean.addInitParameter("loginPassword", "hello"); // 密码
|
||||
servletRegistrationBean.addInitParameter("resetEnable", "false"); // 是否可以重置数据源
|
||||
return servletRegistrationBean ;
|
||||
}
|
||||
@Bean
|
||||
public FilterRegistrationBean filterRegistrationBean() {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean() ;
|
||||
filterRegistrationBean.setFilter(new WebStatFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*"); // 所有请求进行监控处理
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.css,/druid/*");
|
||||
return filterRegistrationBean ;
|
||||
}
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSource druidDataSource() {
|
||||
return new DruidDataSource();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.mldn.microboot.controller;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.mldn.microboot.service.IDeptService;
|
||||
import cn.mldn.microboot.util.controller.AbstractBaseController;
|
||||
|
||||
@RestController
|
||||
public class DeptController extends AbstractBaseController {
|
||||
@Resource
|
||||
private IDeptService deptService ;
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Object list() { // 通过model可以实现内容的传递
|
||||
return this.deptService.list() ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.mldn.microboot.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import cn.mldn.microboot.vo.Dept;
|
||||
@Mapper
|
||||
public interface IDeptDAO {
|
||||
public List<Dept> findAll();
|
||||
public boolean doCreate(Dept vo) ;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.mldn.microboot.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import cn.mldn.microboot.vo.Dept;
|
||||
|
||||
public interface IDeptService {
|
||||
@Transactional(readOnly = true)
|
||||
public List<Dept> list() ;
|
||||
@Transactional(propagation=Propagation.REQUIRED)
|
||||
public boolean add(Dept vo) ;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.mldn.microboot.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.mldn.microboot.dao.IDeptDAO;
|
||||
import cn.mldn.microboot.service.IDeptService;
|
||||
import cn.mldn.microboot.vo.Dept;
|
||||
import cn.mldn.microboot.vo.Member;
|
||||
@Service
|
||||
public class DeptServiceImpl implements IDeptService {
|
||||
@Resource
|
||||
private IDeptDAO deptDAO;
|
||||
@Override
|
||||
public List<Dept> list() {
|
||||
return this.deptDAO.findAll();
|
||||
}
|
||||
@Override
|
||||
public boolean add(Dept vo) {
|
||||
return this.deptDAO.doCreate(vo);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package cn.mldn.microboot.util.controller;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
|
||||
public abstract class AbstractBaseController {
|
||||
@Resource
|
||||
private MessageSource messageSource; // 自动注入此资源对象
|
||||
public String getMessage(String key, String... args) {
|
||||
return this.messageSource.getMessage(key, args, Locale.getDefault());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.mldn.microboot.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Dept implements Serializable {
|
||||
private Long deptno ;
|
||||
private String dname ;
|
||||
public Long getDeptno() {
|
||||
return deptno;
|
||||
}
|
||||
public void setDeptno(Long deptno) {
|
||||
this.deptno = deptno;
|
||||
}
|
||||
public String getDname() {
|
||||
return dname;
|
||||
}
|
||||
public void setDname(String dname) {
|
||||
this.dname = dname;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dept [deptno=" + deptno + ", dname=" + dname + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.mldn.microboot.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Member implements Serializable {
|
||||
private Long mid ;
|
||||
private String name ;
|
||||
private Integer age ;
|
||||
private Date birthday ;
|
||||
private Double salary ;
|
||||
public Long getMid() {
|
||||
return mid;
|
||||
}
|
||||
public void setMid(Long mid) {
|
||||
this.mid = mid;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
public Double getSalary() {
|
||||
return salary;
|
||||
}
|
||||
public void setSalary(Double salary) {
|
||||
this.salary = salary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
DROP DATBASE IF EXISTS mldn ;
|
||||
CREATE DATBASE mldn CHARACTER SET UTF8 ;
|
||||
USE mldn ;
|
||||
CREATE TABLE dept (
|
||||
deptno BIGINT AUTO_INCREMENT ,
|
||||
dname VARCHAR(50) ,
|
||||
CONSTRAINT pk_deptno PRIMARY KEY(deptno)
|
||||
) ;
|
||||
INSERT INTO dept(dname) VALUES ('开发部') ;
|
||||
INSERT INTO dept(dname) VALUES ('财务部') ;
|
||||
INSERT INTO dept(dname) VALUES ('市场部') ;
|
||||
INSERT INTO dept(dname) VALUES ('后勤部') ;
|
||||
INSERT INTO dept(dname) VALUES ('公关部') ;
|
||||
@@ -0,0 +1,22 @@
|
||||
server:
|
||||
port: 80
|
||||
mybatis:
|
||||
config-location: classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径
|
||||
type-aliases-package: cn.mldn.microboot.vo # 定义所有操作类的别名所在包
|
||||
mapper-locations: # 所有的mapper映射文件
|
||||
- classpath:mybatis/mapper/**/*.xml
|
||||
spring:
|
||||
messages:
|
||||
basename: i18n/Messages,i18n/Pages
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource # 配置当前要使用的数据源的操作类型
|
||||
driver-class-name: org.gjt.mm.mysql.Driver # 配置MySQL的驱动程序类
|
||||
url: jdbc:mysql://localhost:3306/mldn # 数据库连接地址
|
||||
username: root # 数据库用户名
|
||||
password: mysqladmin # 数据库连接密码
|
||||
filters: stat,wall,log4j
|
||||
dbcp2: # 进行数据库连接池的配置
|
||||
min-idle: 5 # 数据库连接池的最小维持连接数
|
||||
initial-size: 5 # 初始化提供的连接数
|
||||
max-total: 5 # 最大的连接数
|
||||
max-wait-millis: 200 # 等待连接获取的最大超时时间
|
||||
@@ -0,0 +1,2 @@
|
||||
welcome.url=www.mldn.cn
|
||||
welcome.msg=\u6b22\u8fce{0}\u5149\u4e34\uff01
|
||||
@@ -0,0 +1,2 @@
|
||||
member.add.page=/pages/back/admin/member/member_add.jsp
|
||||
member.add.action=/pages/back/admin/member/member_add.action
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration scan="true">
|
||||
<property name="APP" value="${project.artifactId}" />
|
||||
<property name="LOG_HOME" value="/data/www/log/${APP}" />
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="DETAIL"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<File>${LOG_HOME}/${APP}_detail.log</File>
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/${APP}_detail.log.%d{yyyyMMdd}</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="ACCESS"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<File>${LOG_HOME}/${APP}_access.log</File>
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS};%X{ServiceId};%m%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/${APP}_access.log.%d{yyyyMMdd}</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="ACCESS">
|
||||
<appender-ref ref="ACCESS" />
|
||||
</logger>
|
||||
<logger name="druid.sql.Statement" level="DEBUG" />
|
||||
<logger name="cn.mldn.microboot.dao" level="TRACE" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="DETAIL" />
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.mldn.microboot.dao.IDeptDAO">
|
||||
<select id="findAll" resultType="Dept">
|
||||
SELECT deptno,dname FROM dept ;
|
||||
</select>
|
||||
<insert id="doCreate" parameterType="Dept">
|
||||
INSERT INTO dept(dname) VALUES (#{dname}) ;
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- 进行Mybatis的相应的环境的属性定义 -->
|
||||
<settings> <!-- 在本项目之中开启二级缓存 -->
|
||||
<setting name="cacheEnabled" value="true"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{js/main.js}"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>www.mldn.cn</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
window.onload = function() {
|
||||
console.log("****** www.mldn.cn ******") ;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>www.mldn.cn</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{/js/main.js}"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/images/mldn.ico"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<form th:action="@{/upload}" method="post" enctype="multipart/form-data">
|
||||
姓名:<input type="text" name="name"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
<input type="submit" value="上传"/>
|
||||
</form>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2ANT4kAALWT3AMif079.jpeg')}">查看照片</a>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2AUVINAAA9nfksZs0713.png')}">查看照片</a>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2AOgxGAC-AAARLh5I67.jpeg')}">查看照片</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{/js/main.js}"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/images/mldn.ico"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<img th:src="${image}"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.mldn.microboot;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.mldn.microboot.test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import cn.mldn.microboot.StartSpringBootMain;
|
||||
|
||||
@SpringBootTest(classes = StartSpringBootMain.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
public class TestDataSource {
|
||||
@Resource
|
||||
private DataSource dataSource;
|
||||
@Test
|
||||
public void testConnection() throws Exception {
|
||||
System.out.println(this.dataSource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.mldn.microboot.test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import cn.mldn.microboot.StartSpringBootMain;
|
||||
import cn.mldn.microboot.service.IDeptService;
|
||||
import cn.mldn.microboot.vo.Dept;
|
||||
|
||||
@SpringBootTest(classes = StartSpringBootMain.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
public class TestDeptService {
|
||||
@Resource
|
||||
private IDeptService deptService;
|
||||
@Test
|
||||
public void testList() throws Exception {
|
||||
System.out.println(this.deptService.list());
|
||||
}
|
||||
@Test
|
||||
public void testAdd() throws Exception {
|
||||
Dept dept = new Dept();
|
||||
dept.setDname("测试部");
|
||||
System.out.println(this.deptService.add(dept));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Manifest-Version: 1.0
|
||||
Built-By: foreveriss
|
||||
Build-Jdk: 1.8.0_121
|
||||
Created-By: Maven Integration for Eclipse
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Thu Jun 29 23:45:07 CST 2017
|
||||
version=0.0.1-SNAPSHOT
|
||||
groupId=cn.mldn
|
||||
m2e.projectName=microboot-mybatis
|
||||
m2e.projectLocation=/Users/foreveriss/workspace/microboot/microboot-mybatis
|
||||
artifactId=microboot-mybatis
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.mldn</groupId>
|
||||
<artifactId>microboot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>microboot-mybatis</artifactId>
|
||||
<name>microboot-mybatis</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jetty</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>springloaded</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
server:
|
||||
port: 80
|
||||
mybatis:
|
||||
config-location: classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径
|
||||
type-aliases-package: cn.mldn.microboot.vo # 定义所有操作类的别名所在包
|
||||
mapper-locations: # 所有的mapper映射文件
|
||||
- classpath:mybatis/mapper/**/*.xml
|
||||
spring:
|
||||
messages:
|
||||
basename: i18n/Messages,i18n/Pages
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource # 配置当前要使用的数据源的操作类型
|
||||
driver-class-name: org.gjt.mm.mysql.Driver # 配置MySQL的驱动程序类
|
||||
url: jdbc:mysql://localhost:3306/mldn # 数据库连接地址
|
||||
username: root # 数据库用户名
|
||||
password: mysqladmin # 数据库连接密码
|
||||
filters: stat,wall,log4j
|
||||
dbcp2: # 进行数据库连接池的配置
|
||||
min-idle: 5 # 数据库连接池的最小维持连接数
|
||||
initial-size: 5 # 初始化提供的连接数
|
||||
max-total: 5 # 最大的连接数
|
||||
max-wait-millis: 200 # 等待连接获取的最大超时时间
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
welcome.url=www.mldn.cn
|
||||
welcome.msg=\u6b22\u8fce{0}\u5149\u4e34\uff01
|
||||
@@ -0,0 +1,2 @@
|
||||
member.add.page=/pages/back/admin/member/member_add.jsp
|
||||
member.add.action=/pages/back/admin/member/member_add.action
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration scan="true">
|
||||
<property name="APP" value="${project.artifactId}" />
|
||||
<property name="LOG_HOME" value="/data/www/log/${APP}" />
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="DETAIL"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<File>${LOG_HOME}/${APP}_detail.log</File>
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/${APP}_detail.log.%d{yyyyMMdd}</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="ACCESS"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<File>${LOG_HOME}/${APP}_access.log</File>
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS};%X{ServiceId};%m%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/${APP}_access.log.%d{yyyyMMdd}</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="ACCESS">
|
||||
<appender-ref ref="ACCESS" />
|
||||
</logger>
|
||||
<logger name="druid.sql.Statement" level="DEBUG" />
|
||||
<logger name="cn.mldn.microboot.dao" level="TRACE" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="DETAIL" />
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.mldn.microboot.dao.IDeptDAO">
|
||||
<select id="findAll" resultType="Dept">
|
||||
SELECT deptno,dname FROM dept ;
|
||||
</select>
|
||||
<insert id="doCreate" parameterType="Dept">
|
||||
INSERT INTO dept(dname) VALUES (#{dname}) ;
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- 进行Mybatis的相应的环境的属性定义 -->
|
||||
<settings> <!-- 在本项目之中开启二级缓存 -->
|
||||
<setting name="cacheEnabled" value="true"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{js/main.js}"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>www.mldn.cn</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
window.onload = function() {
|
||||
console.log("****** www.mldn.cn ******") ;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>www.mldn.cn</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{/js/main.js}"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/images/mldn.ico"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<form th:action="@{/upload}" method="post" enctype="multipart/form-data">
|
||||
姓名:<input type="text" name="name"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
照片:<input type="file" name="photo"/><br/>
|
||||
<input type="submit" value="上传"/>
|
||||
</form>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2ANT4kAALWT3AMif079.jpeg')}">查看照片</a>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2AUVINAAA9nfksZs0713.png')}">查看照片</a>
|
||||
<a th:href="@{/show(groupId='group1',fileId='M00/00/00/wKhEtVlTFc2AOgxGAC-AAARLh5I67.jpeg')}">查看照片</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>SpringBoot模版渲染</title>
|
||||
<script type="text/javascript" th:src="@{/js/main.js}"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/images/mldn.ico"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<img th:src="${image}"/>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user