wangyunpeng vor 11 Monaten
Ursprung
Commit
e68ce7944c

+ 2 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/config/PiaoquanCrawlerMysqlConfiguration.java

@@ -4,7 +4,6 @@ import com.zaxxer.hikari.HikariDataSource;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 
 
@@ -12,7 +11,7 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 public class PiaoquanCrawlerMysqlConfiguration {
 
     @Bean(name = "piaoquanCrawlerJdbcTemplate")
-    public JdbcTemplate piaoquanCrawlerJdbcTemplate() {
+    public NamedParameterJdbcTemplate piaoquanCrawlerJdbcTemplate() {
         DataSourceProperties dataSourceProperties = new DataSourceProperties();
         dataSourceProperties.setUsername("crawler");
         dataSourceProperties.setPassword("crawler123456@");
@@ -22,7 +21,7 @@ public class PiaoquanCrawlerMysqlConfiguration {
         dataSource.setMinimumIdle(5);
         dataSource.setMaximumPoolSize(10);
         dataSource.setConnectionTestQuery("select 1");
-        return new JdbcTemplate(dataSource);
+        return new NamedParameterJdbcTemplate(dataSource);
     }
 
     @Bean(name = "programDataJdbcTemplate")

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/strategy/DefaultRecallStrategy.java

@@ -13,6 +13,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -27,7 +28,7 @@ public class DefaultRecallStrategy implements RecallStrategy {
     private FilterService filterService;
     @Autowired
     private AIGCRemoteService aigcRemoteService;
-    @Autowired
+    @Resource(name="piaoquanCrawlerJdbcTemplate")
     NamedParameterJdbcTemplate piaoquanCrawlerJdbcTemplate;
 
     @Override

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewMultiplierStrategy.java

@@ -6,7 +6,6 @@ import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.score.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.NormalizationUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -14,6 +13,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
 @Component
 public class ViewMultiplierStrategy implements ScoreStrategy {
 
-    @Autowired
+    @Resource(name="programDataJdbcTemplate")
     NamedParameterJdbcTemplate programDataJdbcTemplate;
     private JSONObject jsonObject;