SpringBoot常用的依赖添加

Jar打包

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
				<fork>true</fork><!--必须添加这个配置-->
				//热部署不生效就需要添加这个
			</configuration>
		</plugin>
	</plugins>
</build>

如果没有加,则执⾏行行jar包 ,报错如下
java -jar spring-boot-demo-0.0.1-SNAPSHOT.jar
no main manifest attribute, in spring-boot-demo-0.0.1-SNAPSHOT.jar

必备打包、启动命令:
构建:mvn install
构建跳过测试类 mvn install -Dmaven.test.skip=true
target⽬目录下有对应的jar包就是打包后项⽬目
进到对应的target⽬目录启动 java -jar xxxxx.jar 即可
想后台运⾏行行,就⽤用守护进程 nohup java -jar xxx.jar

热部署devtools

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-devtools</artifactId>
	<optional>true</optional>
</dependency>

SpringBoot2.x的单元测试

<!--springboot程序测试依赖,如果是⾃自动创建项⽬目默认添加-->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-test</artifactId>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>4.12</version>
	<scope>test</scope>
</dependency>

thymeleaf依赖

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

idea需要配置的地方

SpringBoot常用的依赖添加_第1张图片

ctrl+shift+alt+/

SpringBoot常用的依赖添加_第2张图片

mysql依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

log4j日志打印

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>1.7.30</version>
</dependency>

并在应用的classpath中创建名为log4j.properties的文件

log4j.rootLogger=ERROR, stdout
log4j.logger.net.xdclass=DEBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

Spring框架依赖包

 <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->         
<dependency> 
       		<groupId>org.springframework</groupId> 
       	 	<artifactId>spring-context</artifactId>
			<version>5.2.5.RELEASE</version> 
</dependency> 

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->         <dependency> 
         	<groupId>org.springframework</groupId> 
          	<artifactId>spring-core</artifactId> 
            <version>5.2.5.RELEASE</version> 
</dependency> 

<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->         <dependency> 
            <groupId>org.springframework</groupId> 
            <artifactId>spring-beans</artifactId> 
            <version>5.2.5.RELEASE</version> 
</dependency>

通用工具包

<dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-lang3</artifactId>
 <version>3.9</version>
</dependency>

跨域身份验证解决⽅案 Json web token包

<!-- JWT相关 -->
<dependency>
 <groupId>io.jsonwebtoken</groupId>
 <artifactId>jjwt</artifactId>
 <version>0.7.0</version>
</dependency>

高性能缓存组件

<!--guava依赖包-->
<dependency>
 <groupId>com.google.guava</groupId>
 <artifactId>guava</artifactId>
 <version>19.0</version>
</dependency>

你可能感兴趣的:(spring,boot)