spring boot集成mybatis使用swiper.js制作中秋祝福H5并打成jar包发布到服务器

github地址:https://github.com/yangyuscript/demo.git

访问地址:http://119.29.169.103:8084/

项目结构图:


1.创建项目

1.1pom文件:

<?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>

	<groupId>com.lin</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.7.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<!--核心模块,包括自动配置支持、日志和YAML-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<!--测试模块,包括JUnit、Hamcrest、Mockito-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<!--热部署-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>
		<!--Web模块-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<!--Mybatis模块-->
		<!--Mybatis核心依赖-->
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.3.0</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.43</version>
		</dependency>
		<!--引入tk.mybatis依赖,实现对实体类的增删改查-->
		<dependency>
			<groupId>tk.mybatis</groupId>
			<artifactId>mapper-spring-boot-starter</artifactId>
			<version>1.1.3</version>
		</dependency>
		<!--引入pagehelper依赖,实现分页功能-->
		<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>1.1.2</version>
		</dependency>
		<!--引入Lombok相关依赖,用于避免数据Get Set方法的重复创建-->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>1.16.18</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-freemarker</artifactId>
		</dependency>
	</dependencies>

	<build>
		<finalName>moon</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>true</fork>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<repositories>
		<repository>
			<id>spring-milestone</id>
			<url>http://repo.spring.io/libs-release</url>
		</repository>
	</repositories>


</project>

application.properties文件:

#spring.datasource.url=jdbc:mysql://localhost:3306/db_sbd
spring.datasource.url=jdbc:mysql://119.29.169.103:3306/db_sbd
spring.datasource.username=你的数据库账号
spring.datasource.password=你的数据库密码
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialize=true
spring.datasource.continueOnError=false
spring.datasource.max-active=100
spring.datasource.max-idle=8
spring.datasource.min-idle=4
spring.datasource.initial-size=10
spring.datasource.test-on-borrow=false
spring.datasource.test-on-return=false
#实体类扫描包
mybatis.type-aliases-package=com.lin.demo.domain
#Mapper.xml文件扫描目录
mybatis.mapper-locations=classpath:mapper/*.xml
#驼峰命名
mybatis.configuration.map-underscore-to-camel-case=true
#tkmapper工具类
mapper.mappers=com.lin.demo.util.MyMapper
mapper.not-empty=false
mapper.identity=MYSQL
pagehelper.helper-dialect=mysql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true
pagehelper.params=count=countSql

#禁止thymeleaf缓存(建议:开发环境设置为false,生成环境设置为true)
spring.thymeleaf.cache=false
server.port=8084

2.项目打成jar包

使用mvn命令:打开cmd,cd到项目根目录运行命令:mvn clean package,会在项目目录下target文件夹中生成jar

3.放到服务器运行jar包

将jar包放到服务器,打开cmd,cd到项目所在父文件夹,运行java -jar jar包名.jar

阅读更多
个人分类: springboot
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭