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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?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> |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步