SpringBoot快速部署
1、使用ieda创建project
选择Spring Initializr 直接next,输入Group、Artifact、选择语言、jdk、版本等信息,点击next,选择需要的jar由Maven直接生成
2、使用maven创建相关项目,此方式需要有自己创建2个文件,分别是resources包下的static、template
以上两种方式都可以,创建完后我们简单的springBoot就算创建完成,下面需要做必要的配置信息
1、创建application.properties文件
#服务器端口
server.port=80
#日志级别
debug=true
#路径上下文
server.servlet.context-path=/yoyo
#字符集
spring.banner.charset=utf-8
#关闭缓存
spring.thymeleaf.cache=false
#日期格式(web)
spring.mvc.date-format=yyyy-MM-dd
#日期格式(json解析中)
spring.jackson.date-format=yyyy-MM-DD
#配置时区(以格林为准向东偏移8)
spring.jackson.time-zone=GMT+8
#日志
logging.file=C:/Users/15810/Desktop/logging/logg.log
#设置日志级别(这属于springBoot自带的日志,springBoot还提供更强大的日志接口)
#logging.level.root=info
#设置logBack日志:只需要在resources包下面,创建logback.xml
目前市面最好用的是日志是logBack,部署简单快捷、日志清晰。
只需要在template包中创建logback.xml就完美解决日志问题
logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="false"> <property name="PROJECT" value="springbootdemo" /> <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径--> <property name="ROOT" value="d:/home/${PROJECT}/" /> <!--日志文件最大的大小--> <property name="FILESIZE" value="50MB" /> <!--日志文件保留天数--> <property name="MAXHISTORY" value="100" /> <timestamp key="DATETIME" datePattern="yyyy-MM-dd HH:mm:ss" /> <!-- 控制台打印 --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder charset="utf-8"> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> </appender> <!-- ERROR 输入到文件,按日期和文件大小 --> <!-- RollingFileAppender 按照每天生成日志文件 --> <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder charset="utf-8"> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--日志文件输出的文件名--> <fileNamePattern>${ROOT}%d/error.%i.log</fileNamePattern> <!--日志文件保留天数--> <maxHistory>${MAXHISTORY}</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!--日志文件最大的大小--> <maxFileSize>${FILESIZE}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> <!-- WARN 输入到文件,按日期和文件大小 --> <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder charset="utf-8"> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>WARN</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${ROOT}%d/warn.%i.log</fileNamePattern> <maxHistory>${MAXHISTORY}</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>${FILESIZE}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> <!-- INFO 输入到文件,按日期和文件大小 --> <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder charset="utf-8"> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>INFO</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${ROOT}%d/info.%i.log</fileNamePattern> <maxHistory>${MAXHISTORY}</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>${FILESIZE}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> <!-- DEBUG 输入到文件,按日期和文件大小 --> <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder charset="utf-8"> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>DEBUG</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${ROOT}%d/debug.%i.log</fileNamePattern> <maxHistory>${MAXHISTORY}</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>${FILESIZE}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> <!-- TRACE 输入到文件,按日期和文件大小 --> <appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder charset="utf-8"> <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n </pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>TRACE</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${ROOT}%d/trace.%i.log</fileNamePattern> <maxHistory>${MAXHISTORY}</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>${FILESIZE}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> <!-- SQL相关日志输出--> <logger name="org.apache.ibatis" level="INFO" additivity="false" /> <logger name="org.mybatis.spring" level="INFO" additivity="false" /> <logger name="com.github.miemiedev.mybatis.paginator" level="INFO" additivity="false" /> <!-- Logger 根目录 --> <!-- 日志输出级别 --> <root level="INFO"> <appender-ref ref="STDOUT" /> <appender-ref ref="DEBUG" /> <appender-ref ref="ERROR" /> <appender-ref ref="WARN" /> <appender-ref ref="INFO" /> <appender-ref ref="TRACE" /> </root> </configuration>