使用IDEA快速搭建SSM+SpringBoot项目
2021-01-22 16:15
标签:aliyun etc src word ruid 测试 mysq util err 一般项目必不可少的包有、controller(控制器)、mapper(接口)、pojo(实体类)、service(接口的实现类)、util(工具类),注意准守规范,包名全小写! resources目录下需创建mapper包,用于与数据库交互 在main下面创建webapp包,用于放一些资源文件,如static、WEB-INF中的jsp、lib等等 代码如下: 自行参考 使用IDEA快速搭建SSM+SpringBoot项目 标签:aliyun etc src word ruid 测试 mysq util err 原文地址:https://www.cnblogs.com/TangJiaXin/p/12888610.html1.创建包
2.配置SpringBoot启动类
package com.apollo.apollodemo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* SpringBoot启动类
*/
@SpringBootApplication
@ServletComponentScan
@MapperScan("com.apollo.apollodemo.mapper") //@MapperScan 用户扫描MyBatis的Mapper接口
public class Apollo extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Apollo.class);
}
public static void main(String[] args) {
SpringApplication.run(Apollo.class, args);
}
}
3.pom文件导入常用的包(这里需要配置好Maven仓库)
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
modelVersion>4.0.0modelVersion>
parent>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-parentartifactId>
version>2.2.7.RELEASEversion>
relativePath/>
parent>
groupId>com.apollogroupId>
artifactId>apollodemoartifactId>
version>0.0.1-SNAPSHOTversion>
packaging>warpackaging>
name>apollodemoname>
description>Demo project for Spring Bootdescription>
properties>
java.version>1.8java.version>
properties>
dependencies>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-webartifactId>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-tomcatartifactId>
scope>providedscope>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-testartifactId>
scope>testscope>
exclusions>
exclusion>
groupId>org.junit.vintagegroupId>
artifactId>junit-vintage-engineartifactId>
exclusion>
exclusions>
dependency>
dependency>
groupId>javax.servletgroupId>
artifactId>jstlartifactId>
dependency>
dependency>
groupId>log4jgroupId>
artifactId>log4jartifactId>
version>1.2.17version>
dependency>
dependency>
groupId>org.mybatis.spring.bootgroupId>
artifactId>mybatis-spring-boot-starterartifactId>
version>1.1.1version>
dependency>
dependency>
groupId>mysqlgroupId>
artifactId>mysql-connector-javaartifactId>
dependency>
dependency>
groupId>com.alibabagroupId>
artifactId>druidartifactId>
version>1.0.9version>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-devtoolsartifactId>
dependency>
dependency>
groupId>org.projectlombokgroupId>
artifactId>lombokartifactId>
version>1.18.8version>
scope>providedscope>
dependency>
dependency>
groupId>com.alibabagroupId>
artifactId>fastjsonartifactId>
version>1.2.35version>
dependency>
dependency>
groupId>org.apache.poigroupId>
artifactId>poiartifactId>
version>3.17version>
dependency>
dependency>
groupId>com.aliyungroupId>
artifactId>aliyun-java-sdk-coreartifactId>
version>4.0.8version>
dependency>
dependency>
groupId>com.aliyungroupId>
artifactId>aliyun-java-sdk-dysmsapiartifactId>
version>1.1.0version>
dependency>
dependency>
groupId>org.apache.poigroupId>
artifactId>poi-ooxmlartifactId>
version>3.17version>
dependency>
dependency>
groupId>com.alibabagroupId>
artifactId>easyexcelartifactId>
version>1.1.2-beta5version>
dependency>
dependency>
groupId>net.sf.json-libgroupId>
artifactId>json-libartifactId>
version>2.4version>
classifier>jdk15classifier>
exclusions>
exclusion>
groupId>commons-collectionsgroupId>
artifactId>commons-collectionsartifactId>
exclusion>
exclusion>
groupId>commons-langgroupId>
artifactId>commons-langartifactId>
exclusion>
exclusion>
groupId>commons-logginggroupId>
artifactId>commons-loggingartifactId>
exclusion>
exclusions>
dependency>
dependency>
groupId>commons-langgroupId>
artifactId>commons-langartifactId>
version>2.6version>
dependency>
dependency>
groupId>org.apache.commonsgroupId>
artifactId>commons-ioartifactId>
version>1.3.2version>
dependency>
dependency>
groupId>com.aliyun.ossgroupId>
artifactId>aliyun-sdk-ossartifactId>
version>2.5.0version>
dependency>
dependency>
groupId>net.sf.json-libgroupId>
artifactId>json-libartifactId>
version>2.4version>
classifier>jdk15classifier>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-tomcatartifactId>
scope>providedscope>
dependency>
dependencies>
build>
plugins>
plugin>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>
4.项目全局配置文件application.properties(这里也可以改成其它格式的文件)
#配置端口号
server.port=88
#配置MYSQL数据库
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://数据库链接/数据库名称?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#配置控制器返回路径
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
mybatis.type-aliases-package=com.apollo.appllodemo.pojo
mybatis.mapper-locations=classpath:mapper/*.xml
#配置时间格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.serialization.write-dates-as-timestamps=false
#配置日志文件
logging.level.com.muen.mapper=debug
上一篇:守护线程
下一篇:配置centos7 java环境
文章标题:使用IDEA快速搭建SSM+SpringBoot项目
文章链接:http://soscw.com/index.php/essay/45502.html