Browse Source

修复tomcat问题

yinhao 3 years ago
parent
commit
90f1e0def1

+ 20 - 0
huimv-mobile-video/huimv-manager/pom.xml

@@ -65,5 +65,25 @@
 
 	</dependencies>
 
+	<build>
+		<finalName>manager</finalName>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<fork>true</fork>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
 
 </project>

+ 0 - 1
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/HuimvMobileManagerApplication.java

@@ -1,6 +1,5 @@
 package com.huimv.manager;
 
-import cn.dustlight.captcha.annotations.EnableCaptcha;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 

+ 66 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/FastJson2JsonRedisSerializer.java

@@ -0,0 +1,66 @@
+package com.huimv.manager.config;
+
+import cn.hutool.core.util.ObjectUtil;
+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;
+
+/**
+ * redis序列化器
+ *
+ * @author xuyuxiang
+ * @date 2020/3/30 18:30
+ */
+public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> {
+
+    private final Class<T> clazz;
+
+    static {
+        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
+    }
+
+    /**
+     * 构造函数
+     *
+     * @author xuyuxiang
+     * @date 2020/4/8 19:12
+     */
+    public FastJson2JsonRedisSerializer(Class<T> clazz) {
+        super();
+        this.clazz = clazz;
+    }
+
+    /**
+     * 序列化
+     *
+     * @author xuyuxiang
+     * @date 2020/4/8 19:12
+     */
+    @Override
+    public byte[] serialize(T t) throws SerializationException {
+        if (ObjectUtil.isEmpty(t)) {
+            return new byte[0];
+        }
+        return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(Charset.defaultCharset());
+    }
+
+    /**
+     * 反序列化
+     *
+     * @author xuyuxiang
+     * @date 2020/4/8 19:12
+     */
+    @Override
+    public T deserialize(byte[] bytes) throws SerializationException {
+        if (ObjectUtil.isEmpty(bytes)) {
+            return null;
+        }
+        String str = new String(bytes, Charset.defaultCharset());
+        return (T) JSON.parseObject(str, clazz);
+    }
+
+}

+ 46 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/RedisConfigure.java

@@ -0,0 +1,46 @@
+package com.huimv.manager.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+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.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @author yinhao
+ */
+@Configuration
+public class RedisConfigure {
+
+    @Bean
+    @ConditionalOnClass(RedisOperations.class)
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
+        RedisTemplate<String, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(factory);
+
+        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        mapper.activateDefaultTyping(mapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(mapper);
+
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+        // key采用 String的序列化方式
+        template.setKeySerializer(stringRedisSerializer);
+        // hash的 key也采用 String的序列化方式
+        template.setHashKeySerializer(stringRedisSerializer);
+        // value序列化方式采用 jackson
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        // hash的 value序列化方式采用 jackson
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
+        template.afterPropertiesSet();
+
+        return template;
+    }
+}

+ 6 - 4
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/CaptchaController.java

@@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit;
  * <p>
  * 验证码前端控制器
  * </p>
+ *
  * @Author yinhao
  * @Date 2021/4/19 11:56
  */
@@ -33,11 +34,12 @@ public class CaptchaController {
 
     /**
      * 获取验证码
+     *
      * @param request
      * @param response
      */
     @GetMapping("/send")
-    public void createImg(HttpServletRequest request, HttpServletResponse response)  {
+    public void createImg(HttpServletRequest request, HttpServletResponse response) {
         try {
             //设置响应类型,告诉浏览器输出的内容为图片
             response.setContentType("image/jpeg");
@@ -48,12 +50,12 @@ public class CaptchaController {
             VerifyUtil randomValidateCode = new VerifyUtil();
             //输出验证码图片
             String code = randomValidateCode.getRandcode(request, response);
-            log.info(code);
+//            log.info(code);
             //将生成的随机验证码存放到redis中
             String remoteHost = request.getRemoteHost();
-            redisTemplate.opsForValue().set(remoteHost,code,300, TimeUnit.SECONDS);
+            redisTemplate.opsForValue().set(remoteHost, code, 300, TimeUnit.SECONDS);
         } catch (Exception e) {
-            log.error("获取验证码异常:",e);
+            log.error("获取验证码异常:", e);
             throw new RRException("获取验证码失败!");
         }
     }

+ 1 - 1
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserLoginController.java

@@ -43,7 +43,7 @@ public class MobileUserLoginController {
         if (!redisCode.equals(code.toUpperCase())) {
             return R.error("验证码错误!");
         }
-        log.info(code);
+//        log.info(code);
         return mobileUserService.login(account, password, code);
     }
 }

+ 1 - 1
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUnit.java

@@ -48,7 +48,7 @@ public class MobileUnit implements Serializable {
 
 
     @Column(name = "fid")
-    @ApiModelProperty("fid")
+    @ApiModelProperty(value = "fid",example = "1")
     private Integer fid;
 
 }

+ 22 - 5
huimv-mobile-video/huimv-manager/src/main/resources/application-dev.yml

@@ -3,14 +3,18 @@ server:
 spring:
   application:
     name: huimv-manager
+  servlet:
+    multipart:
+      max-request-size: 100MB
+      max-file-size: 100MB
 
   datasource:
-    url: jdbc:mysql://192.168.1.7:3306/huimv_ql_breed_video?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_breed_video?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
     username: root
     password: hm123456
     driver-class-name: com.mysql.cj.jdbc.Driver
   jpa:
-    show-sql: true
+#    show-sql: true
     database: mysql
 #    hibernate:
 #      ddl-auto: update
@@ -27,11 +31,24 @@ spring:
 #      redis:
 #        key-prefix: "CAPTCHA_CODE"
 
-    #  redis:
+  redis:
+    database: 0
+    host: 122.112.224.199
+    port: 6379
+    password: hm123456
+    jedis:
+      pool:
+        max-active: 20
+        max-wait: -1
+        max-idle: 10
+        min-idle: 0
+    timeout: 5000
+
+#  redis:
 #    database: 0
-#    host: 119.3.84.55
+#    host: 127.0.0.1
 #    port: 6379
-#    password: hm123456
+#    password:
 #    jedis:
 #      pool:
 #        max-active: 20

+ 1 - 1
huimv-mobile-video/pom.xml

@@ -79,7 +79,7 @@
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>fastjson</artifactId>
-			<version>1.2.24</version>
+			<version>1.2.75</version>
 		</dependency>
 		<dependency>
 			<groupId>org.projectlombok</groupId>