Spring Boot Setting

Some Spring Boot Setting and Memorandum Clause

Posted by MichaelChen on 2020-11-26
Estimated Reading Time 1 Minutes
Words 297 In Total
Viewed Times

Spring Boot Setting & Memorandum Clause

Pom Setting

Export Setting

plagin

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
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--值为true是指打包时包含scope为system的第三方Jar包-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/resources/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>

dependency

1
2
3
4
5
6
7
<dependency>
<groupId>com.rxtxcomm</groupId> //suit yourself
<artifactId>sdk</artifactId> //suit yourseld
<scope>system</scope> //suit your self
<version>3.0.0.0</version> //suit your self
<systemPath>${pom.basedir}/src/main/resources/lib/RXTXcomm.jar</systemPath> //path
</dependency>

Annotation

  • @Transactional

    1
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
  • @Component
    @ServerEndpoint

    1
    2
    @Component
    @ServerEndpoint("/websocket/w")

Configuration

  • GlobalCorsConfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class GlobalCorsConfig {

@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.addAllowedOrigin("*");
config.setAllowCredentials(true);
config.addAllowedMethod("*");
config.addAllowedHeader("*");
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
configSource.registerCorsConfiguration("/**", config);
return new CorsFilter(configSource);
}

}

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !