真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

怎么在中springcloud中對pom.xml進(jìn)行配置-創(chuàng)新互聯(lián)

怎么在中springcloud中對pom.xml進(jìn)行配置?針對這個問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

成都創(chuàng)新互聯(lián)公司專注于蘭山網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供蘭山營銷型網(wǎng)站建設(shè),蘭山網(wǎng)站制作、蘭山網(wǎng)頁設(shè)計、蘭山網(wǎng)站官網(wǎng)定制、成都微信小程序服務(wù),打造蘭山網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供蘭山網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

1、父工程

pom

 Maven
 
 http://maven.apache.org/
 2001

 
  
   website
   scp://webhost.company.com/www/website
  
 

 
  UTF-8
  12
  12
  4.12
  1.18.10
  1.2.17
  8.0.18
  1.1.16
  2.1.1
 

 
  
   
   
    com.alibaba.cloud
    spring-cloud-alibaba-dependencies
    2.1.0.RELEASE
    pom
    import
   

   
    org.apache.maven.plugins
    maven-project-info-reports-plugin
    3.0.0
   
   
    
   org.springframework.cloud
   spring-cloud-starter-gateway
   
   
    org.springframework.boot
    spring-boot-dependencies
    2.2.2.RELEASE
    pom
    import
   
   
   
    org.springframework.cloud
    spring-cloud-dependencies
    Hoxton.SR1
    pom
    import
   
   
    com.alibaba.cloud
    spring-cloud-alibaba-dependencies
    2.1.0.RELEASE
    pom
    import
   
   
   
    mysql
    mysql-connector-java
    ${mysql.version}
    runtime
   
   
   
    com.alibaba
    druid
    ${druid.version}
   
   
    org.mybatis.spring.boot
    mybatis-spring-boot-starter
    ${mybatis.spring.boot.version}
   
   
   
    junit
    junit
    ${junit.version}
   
   
   
    log4j
    log4j
    ${log4j.version}
   
  

 
 
 
  
   
    org.springframework.boot
    spring-boot-maven-plugin
    
     true
     true
    
   
  
 

2、子工程

 
  
   org.example
   common-service
   ${project.version}
  
  
   com.aliyun.oss
   aliyun-sdk-oss
   2.8.2
  
  

   com.github.pagehelper
   pagehelper-spring-boot-starter
   1.2.10

  
  
   commons-lang
   commons-lang
   2.6
  
  
   io.springfox
   springfox-swagger2
   2.9.2
  
  
   io.github.openfeign
   feign-httpclient
  
  
   com.alibaba.csp
   sentinel-datasource-nacos
  
  
   io.springfox
   springfox-swagger-ui
   2.9.2
  
  
   org.springframework.cloud
   spring-cloud-starter-openfeign
  
  
  
   org.example
   common
   ${project.version}
  
  
   mysql
   mysql-connector-java
   8.0.18
  
  
   com.fasterxml.jackson.core
   jackson-core
   2.9.0
  
  
   com.fasterxml.jackson.core
   jackson-annotations
   2.9.0
  
  
   com.fasterxml.jackson.core
   jackson-databind
   2.9.0
  
  
   com.alibaba.cloud
   spring-cloud-starter-alibaba-nacos-config
  
  
   com.alibaba.cloud
   spring-cloud-starter-alibaba-nacos-discovery
  
  
   org.springframework.boot
   spring-boot-starter-amqp
  
  
   org.mybatis.spring.boot
   mybatis-spring-boot-starter
  
  
   org.springframework.boot
   spring-boot-starter-websocket
  
  
   com.alibaba
   fastjson
   1.2.41
  
  
    org.springframework.boot
    spring-boot-starter-data-redis
    
     
      redis.clients
      jedis
     
     
      io.lettuce
      lettuce-core
     
    
   
   
    redis.clients
    jedis
   
  
   org.springframework.boot
   spring-boot-starter-web
  
  
   org.projectlombok
   lombok
   true
  
 

3、swapper配置

package main.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
 @Bean
 public Docket createRestApi() {
  return new Docket(DocumentationType.SWAGGER_2)
    .apiInfo(apiInfo())
    .select()
    .apis(RequestHandlerSelectors.basePackage("main.controller"))
    .paths(PathSelectors.any())
    .build();

 }

 //配置在線文檔的基本信息
 private ApiInfo apiInfo() {
  return new ApiInfoBuilder()
    .title("springboot利用swagger構(gòu)建api文檔")
    .description("簡單優(yōu)雅的restfun風(fēng)格,https://me.csdn.net/blog/miachen520")
    .termsOfServiceUrl("https://me.csdn.net/blog/miachen520")
    .version("1.0")
    .build();

 }
}

4、跨域配置

package main.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class webConfig implements WebMvcConfigurer {

 @Override
 public void addCorsMappings(CorsRegistry registry) {
  // 設(shè)置允許跨域的路徑
  registry.addMapping("/**")
    // 設(shè)置允許跨域請求的域名
    .allowedOrigins("*")
    // 是否允許證書
    .allowCredentials(true)
    .allowedMethods("*")
    .maxAge(3600);
 }
}

5、Redis序列化

serializer:

package main.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;
import java.nio.charset.Charset;
public class FastJsonRedisSerializer implements RedisSerializer {
 public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 private Class clazz;
 public FastJsonRedisSerializer(Class clazz) {

  super();

  this.clazz = clazz;

 }

 @Override
 public byte[] serialize(T t) throws SerializationException {

  if (null == t) {

   return new byte[0];

  }

  return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);

 }

 @Override
 public T deserialize(byte[] bytes) throws SerializationException {

  if (null == bytes || bytes.length <= 0) {

   return null;

  }

  String str = new String(bytes, DEFAULT_CHARSET);
  ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
  return (T) JSON.parseObject(str, clazz);
 }
}

config:

package main.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration

@ConditionalOnClass(RedisOperations.class)

@EnableConfigurationProperties(RedisProperties.class)

public class redisConfig {
 @Bean

 @ConditionalOnMissingBean(name = "redisTemplate")

 public RedisTemplate redisTemplate(

   RedisConnectionFactory redisConnectionFactory) {

  RedisTemplate template = new RedisTemplate<>();

  //使用fastjson序列化

  FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);

  // value值的序列化采用fastJsonRedisSerializer

  template.setValueSerializer(fastJsonRedisSerializer);

  template.setHashValueSerializer(fastJsonRedisSerializer);

  // key的序列化采用StringRedisSerializer

  template.setKeySerializer(new StringRedisSerializer());

  template.setHashKeySerializer(new StringRedisSerializer());

  template.setConnectionFactory(redisConnectionFactory);

  return template;

 }

 @Bean
 @ConditionalOnMissingBean(StringRedisTemplate.class)

 public StringRedisTemplate stringRedisTemplate(

   RedisConnectionFactory redisConnectionFactory) {

  StringRedisTemplate template = new StringRedisTemplate();

  template.setConnectionFactory(redisConnectionFactory);

  return template;

 }
}

關(guān)于怎么在中springcloud中對pom.xml進(jìn)行配置問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。


本文題目:怎么在中springcloud中對pom.xml進(jìn)行配置-創(chuàng)新互聯(lián)
分享路徑:http://weahome.cn/article/dsddpp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部