怎么在中springcloud中对pom.xml进行配置-创新互联
怎么在中springcloud中对pom.xml进行配置?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
成都创新互联公司专注于兰山网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供兰山营销型网站建设,兰山网站制作、兰山网页设计、兰山网站官网定制、成都微信小程序服务,打造兰山网络公司原创品牌,更为您提供兰山网站排名全网营销落地服务。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构建api文档") .description("简单优雅的restfun风格,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) { // 设置允许跨域的路径 registry.addMapping("/**") // 设置允许跨域请求的域名 .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 FastJsonRedisSerializerimplements 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
关于怎么在中springcloud中对pom.xml进行配置问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。
网站标题:怎么在中springcloud中对pom.xml进行配置-创新互联
分享路径:http://ybzwz.com/article/dsddpp.html