这里记录下简单的Springboot项目
1.新建一个project
2.选择spring initializr选项然后下一步,JDK1.8(自行选择)
这里有个问题:有的人在选项里没有这个选项只有Spring,这是因为你的idea没有安装Spring boot插件.
在settings-->plugins-->勾选Spring boot 后面的方框然后重启idea就可以看到这个选项了.
4.打开项目运行
可以看到默认端口是8080
需要更改端口的时候在配置文件'application.properties'里更改server.port参数,默认里面是没有内容的,把它填上就好了
这里把pom.xml里的内容粘出来方便eclipse的各位粘贴
<?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.example</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
* * *
这里在附带的写一些配置信息,方便下次需要时添加,ctrl+f搜索一下自己需要的,没找到的可以去官网找
*# LOGGING*
logging.config= *# Location of the logging configuration file. For instance `classpath:logback.xml` for Logback*
logging.exception-conversion-word=%wEx *# Conversion word used when logging exceptions.*
logging.file= *# Log file name. For instance `myapp.log`*
logging.level.*= *# Log levels severity mapping. For instance `logging.level.org.springframework=DEBUG`*
logging.path= *# Location of the log file. For instance `/var/log`*
logging.pattern.console= *# Appender pattern for output to the console. Only supported with the default logback setup.*
logging.pattern.file= *# Appender pattern for output to the file. Only supported with the default logback setup.*
logging.pattern.level= *# Appender pattern for log level (default %5p). Only supported with the default logback setup.*
logging.register-shutdown-hook=false *# Register a shutdown hook for the logging system when it is initialized.*
*# AOP*
spring.aop.auto=true *# Add @EnableAspectJAutoProxy.*
spring.aop.proxy-target-class=false *# Whether subclass-based (CGLIB) proxies are to be created (true) as opposed to standard Java interface-based proxies (false).*
*# ----------------------------------------*
*# WEB PROPERTIES*
*# ----------------------------------------*
*# EMBEDDED SERVER CONFIGURATION (*[ServerProperties](https://github.com/spring-projects/spring-boot/tree/v1.5.2.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java))
server.address= *# Network address to which the server should bind to.*
server.compression.enabled=false *# If response compression is enabled.*
server.compression.excluded-user-agents= *# List of user-agents to exclude from compression.*
server.compression.mime-types= *# Comma-separated list of MIME types that should be compressed. For instance `text/html,text/css,application/json`*
server.compression.min-response-size= *# Minimum response size that is required for compression to be performed. For instance 2048*
server.connection-timeout= *# Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.*
server.context-parameters.*= *# Servlet context init parameters. For instance `server.context-parameters.a=alpha`*
server.context-path= *# Context path of the application.*
server.display-name=application *# Display name of the application.*
server.max-http-header-size=0 *# Maximum size in bytes of the HTTP message header.*
server.error.include-stacktrace=never *# When to include a "stacktrace" attribute.*
server.error.path=/error *# Path of the error controller.*
server.error.whitelabel.enabled=true *# Enable the default error page displayed in browsers in case of a server error.*
server.jetty.acceptors= *# Number of acceptor threads to use.*
server.jetty.max-http-post-size=0 *# Maximum size in bytes of the HTTP post or put content.*
server.jetty.selectors= *# Number of selector threads to use.*
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet *# The class name of the JSP servlet.*
server.jsp-servlet.init-parameters.*= *# Init parameters used to configure the JSP servlet*
server.jsp-servlet.registered=true *# Whether or not the JSP servlet is registered*
server.port=8080 *# Server HTTP port.*
server.server-header= *# Value to use for the Server response header (no header is sent if empty)*
server.servlet-path=/ *# Path of the main dispatcher servlet.*
server.use-forward-headers= *# If X-Forwarded-* headers should be applied to the HttpRequest.*
server.session.cookie.comment= *# Comment for the session cookie.*
server.session.cookie.domain= *# Domain for the session cookie.*
server.session.cookie.http-only= *# "HttpOnly" flag for the session cookie.*
server.session.cookie.max-age= *# Maximum age of the session cookie in seconds.*
server.session.cookie.name= *# Session cookie name.*
server.session.cookie.path= *# Path of the session cookie.*
server.session.cookie.secure= *# "Secure" flag for the session cookie.*
server.session.persistent=false *# Persist session data between restarts.*
server.session.store-dir= *# Directory used to store session data.*
server.session.timeout= *# Session timeout in seconds.*
server.session.tracking-modes= *# Session tracking modes (one or more of the following: "cookie", "url", "ssl").*
server.ssl.ciphers= *# Supported SSL ciphers.*
server.ssl.client-auth= *# Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.*
server.ssl.enabled= *# Enable SSL support.*
server.ssl.enabled-protocols= *# Enabled SSL protocols.*
server.ssl.key-alias= *# Alias that identifies the key in the key store.*
server.ssl.key-password= *# Password used to access the key in the key store.*
server.ssl.key-store= *# Path to the key store that holds the SSL certificate (typically a jks file).*
server.ssl.key-store-password= *# Password used to access the key store.*
server.ssl.key-store-provider= *# Provider for the key store.*
server.ssl.key-store-type= *# Type of the key store.*
server.ssl.protocol=TLS *# SSL protocol to use.*
server.ssl.trust-store= *# Trust store that holds SSL certificates.*
server.ssl.trust-store-password= *# Password used to access the trust store.*
server.ssl.trust-store-provider= *# Provider for the trust store.*
server.ssl.trust-store-type= *# Type of the trust store.*
server.tomcat.accept-count= *# Maximum queue length for incoming connection requests when all possible request processing threads are in use.*
server.tomcat.accesslog.buffered=true *# Buffer output such that it is only flushed periodically.*
server.tomcat.accesslog.directory=logs *# Directory in which log files are created. Can be relative to the tomcat base dir or absolute.*
server.tomcat.accesslog.enabled=false *# Enable access log.*
server.tomcat.accesslog.pattern=common *# Format pattern for access logs.*
server.tomcat.accesslog.prefix=access_log *# Log file name prefix.*
server.tomcat.accesslog.rename-on-rotate=false *# Defer inclusion of the date stamp in the file name until rotate time.*
server.tomcat.accesslog.request-attributes-enabled=false *# Set request attributes for IP address, Hostname, protocol and port used for the request.*
server.tomcat.accesslog.rotate=true *# Enable access log rotation.*
server.tomcat.accesslog.suffix=.log *# Log file name suffix.*
server.tomcat.additional-tld-skip-patterns= *# Comma-separated list of additional patterns that match jars to ignore for TLD scanning.*
server.tomcat.background-processor-delay=30 *# Delay in seconds between the invocation of backgroundProcess methods.*
server.tomcat.basedir= *# Tomcat base directory. If not specified a temporary directory will be used.*
server.tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\
169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\
127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}*# regular expression matching trusted IP addresses.*
server.tomcat.max-connections= *# Maximum number of connections that the server will accept and process at any given time.*
server.tomcat.max-http-post-size=0 *# Maximum size in bytes of the HTTP post content.*
server.tomcat.max-threads=0 *# Maximum amount of worker threads.*
server.tomcat.min-spare-threads=0 *# Minimum amount of worker threads.*
server.tomcat.port-header=X-Forwarded-Port *# Name of the HTTP header used to override the original port value.*
server.tomcat.protocol-header= *# Header that holds the incoming protocol, usually named "X-Forwarded-Proto".*
server.tomcat.protocol-header-https-value=https *# Value of the protocol header that indicates that the incoming request uses SSL.*
server.tomcat.redirect-context-root= *# Whether requests to the context root should be redirected by appending a / to the path.*
server.tomcat.remote-ip-header= *# Name of the http header from which the remote ip is extracted. For instance `X-FORWARDED-FOR`*
server.tomcat.uri-encoding=UTF-8 *# Character encoding to use to decode the URI.*
server.undertow.accesslog.dir= *# Undertow access log directory.*
server.undertow.accesslog.enabled=false *# Enable access log.*
server.undertow.accesslog.pattern=common *# Format pattern for access logs.*
server.undertow.accesslog.prefix=access_log. *# Log file name prefix.*
server.undertow.accesslog.rotate=true *# Enable access log rotation.*
server.undertow.accesslog.suffix=log *# Log file name suffix.*
server.undertow.buffer-size= *# Size of each buffer in bytes.*
server.undertow.buffers-per-region= *# Number of buffer per region.*
server.undertow.direct-buffers= *# Allocate buffers outside the Java heap.*
server.undertow.io-threads= *# Number of I/O threads to create for the worker.*
server.undertow.max-http-post-size=0 *# Maximum size in bytes of the HTTP post content.*
server.undertow.worker-threads= *# Number of worker threads.*