Skip to content

Commit 18528db

Browse files
committed
initial commit
0 parents  commit 18528db

File tree

20 files changed

+284
-0
lines changed

20 files changed

+284
-0
lines changed

.classpath

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="src" path="target/generated-sources/annotations">
36+
<attributes>
37+
<attribute name="optional" value="true"/>
38+
<attribute name="maven.pomderived" value="true"/>
39+
<attribute name="ignore_optional_problems" value="true"/>
40+
<attribute name="m2e-apt" value="true"/>
41+
</attributes>
42+
</classpathentry>
43+
<classpathentry kind="output" path="target/classes"/>
44+
</classpath>

.project

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>test-spring-boot-mybatis-mvc</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.m2e.core.maven2Builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.jdt.core.javanature</nature>
26+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
27+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
28+
</natures>
29+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.apt.aptEnabled=false

.settings/org.eclipse.jdt.core.prefs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3+
org.eclipse.jdt.core.compiler.compliance=1.8
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.processAnnotations=disabled
6+
org.eclipse.jdt.core.compiler.source=1.8

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RUNNING
2+
mvn spring-boot:run
3+
4+
DEPLOYING to existing tomcat
5+
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

pom.xml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.abstractdog</groupId>
5+
<artifactId>test-spring-boot-mybatis-mvc</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>war</packaging>
8+
9+
<parent>
10+
<groupId>org.springframework.boot</groupId>
11+
<artifactId>spring-boot-starter-parent</artifactId>
12+
<version>1.5.9.RELEASE</version>
13+
</parent>
14+
15+
<properties>
16+
<start-class>com.lightport.spring.boot.mybatis.Application</start-class>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-web</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.mybatis.spring.boot</groupId>
26+
<artifactId>mybatis-spring-boot-starter</artifactId>
27+
<version>1.3.1</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>mysql</groupId>
31+
<artifactId>mysql-connector-java</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-tomcat</artifactId>
36+
<scope>provided</scope>
37+
</dependency>
38+
39+
</dependencies>
40+
41+
<build>
42+
<finalName>${project.artifactId}</finalName>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-compiler-plugin</artifactId>
47+
<configuration>
48+
<source>1.8</source>
49+
<target>1.8</target>
50+
</configuration>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.abstractdog.spring.boot.mybatis;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.boot.builder.SpringApplicationBuilder;
8+
import org.springframework.boot.web.support.SpringBootServletInitializer;
9+
10+
@SpringBootApplication
11+
public class Application extends SpringBootServletInitializer {
12+
private static Logger logger = LoggerFactory.getLogger(Application.class);
13+
14+
@Override
15+
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
16+
return application.sources(Application.class);
17+
}
18+
19+
public static void main(String[] args) throws Exception {
20+
logger.info("running application...");
21+
SpringApplication.run(Application.class, args);
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.abstractdog.spring.boot.mybatis.controller;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RequestMethod;
5+
import org.springframework.web.bind.annotation.RestController;
6+
7+
import com.abstractdog.spring.boot.mybatis.service.DaoService;
8+
9+
@RestController
10+
@RequestMapping(value = "/")
11+
public class Controller {
12+
13+
private final DaoService daoService;
14+
15+
public Controller(DaoService daoService) {
16+
this.daoService = daoService;
17+
}
18+
19+
@RequestMapping(value = "/select1", method = RequestMethod.GET)
20+
public String select1() {
21+
return daoService.select1();
22+
}
23+
24+
@RequestMapping(value = "/select1xml", method = RequestMethod.GET)
25+
public String select1xml() {
26+
return daoService.select1xml();
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.abstractdog.spring.boot.mybatis.dao;
2+
3+
import org.apache.ibatis.session.SqlSession;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.stereotype.Component;
6+
7+
@Component
8+
public class Dao {
9+
10+
@Autowired
11+
private SqlSession sqlSession;
12+
13+
@Autowired
14+
private XmlMapper xmlMapper;
15+
16+
public String select1() {
17+
return sqlSession.selectOne("select1", null);
18+
}
19+
20+
public String select1xml() {
21+
return xmlMapper.select1xml();
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.abstractdog.spring.boot.mybatis.dao;
2+
3+
import org.apache.ibatis.annotations.Mapper;
4+
import org.apache.ibatis.annotations.Select;
5+
6+
@Mapper
7+
public interface IMapper {
8+
@Select("SELECT 1")
9+
String select1();
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.abstractdog.spring.boot.mybatis.dao;
2+
3+
import org.apache.ibatis.annotations.Mapper;
4+
5+
@Mapper
6+
public interface XmlMapper {
7+
String select1xml ();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.abstractdog.spring.boot.mybatis.service;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.stereotype.Service;
5+
6+
import com.abstractdog.spring.boot.mybatis.dao.Dao;
7+
8+
@Service
9+
public class DaoService {
10+
private final Dao dao;
11+
12+
@Autowired
13+
public DaoService(Dao dao) {
14+
this.dao = dao;
15+
}
16+
17+
public String select1() {
18+
return dao.select1();
19+
}
20+
21+
public String select1xml() {
22+
return dao.select1xml();
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/information_schema
2+
spring.datasource.username=root
3+
spring.datasource.password=12345
4+
spring.datasource.test-on-borrow=true
5+
spring.datasource.test-while-idle=true
6+
spring.datasource.validation-query=SELECT 1;
7+
spring.datasource.driverClassName=com.mysql.jdbc.Driver
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
3+
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
4+
<mapper namespace="com.lightport.spring.boot.mybatis.dao.XmlMapper">
5+
<select id="select1xml" resultType="string">
6+
SELECT 1
7+
</select>
8+
</mapper>

src/test/java/needit

Whitespace-only changes.

src/test/resources/needit

Whitespace-only changes.

target/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/classes/
2+
/test-classes/
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/META-INF/

0 commit comments

Comments
 (0)