小编Reb*_*orn的帖子

Spring Security循环bean依赖

我正在研究Vaadin spring应用程序.我唯一能说的是,用户的身份验证/授权必须通过查询数据库来完成jdbcTemplate.如何解决这个问题?我正在使用Spring Boot 1.4.2.RELEASE.

Description:
The dependencies of some of the beans in the application context form a cycle:
???????
|  jdbcAccountRepository defined in file [repositories\JdbcAccountRepository.class]
?     ?
|  securityConfiguration.WebSecurityConfig (field services.JdbcUserDetailsServicessecurity.SecurityConfiguration$WebSecurityConfig.userDetailsService)
?     ?
|  jdbcUserDetailsServices (field repositories.JdbcAccountRepository services.JdbcUserDetailsServices.repository)
???????
Run Code Online (Sandbox Code Playgroud)

原始代码如下所示:

AccountRepository:

public interface AccountRepository {
    void createAccount(Account user) throws UsernameAlreadyInUseException;
    Account findAccountByUsername(String username);
}
Run Code Online (Sandbox Code Playgroud)

JdbcAccountRepository:

@Repository
public class JdbcAccountRepository implements AccountRepository {

    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    private final JdbcTemplate jdbcTemplate;
    private final PasswordEncoder passwordEncoder;

    @Autowired …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-jdbc vaadin

23
推荐指数
5
解决办法
3万
查看次数

Mutation和Query之间有什么区别

到目前为止,我正在阅读GraphQL学习部分,Query并在其中Mutation进行描述.然而,缺乏显示和/或描述它们之间差异的真实示例,最重要的是 - 何时适合使用它.

非常感谢您的解释.

graphql

14
推荐指数
5
解决办法
3705
查看次数

Google收回v3问题

为什么recaptcha v3会抛出错误?...当我在同一页面上第二次检查访客的人性时?

令牌显然不是重复的.......那么重复是什么?

第一个标记:

03AEMEkEl76Kn0nMhKlgY8dMOAD2g3zGIHoGOqz95jEFKl8A24gADw-2gBipDYcU7G_TWSqpuWyNa62CIk-tYdreevde0p1lJg_3wwZlmD9giDSdPb_He-mTsIqv0tMuEroJLLArCI4vfbZjcCZ6BYokYEhYbCU-Qqdx9YbqgRG1JJDxE8LRagR0cPY8mfQZ5bZ7KGK8Dfqe8avqOy18RvIcYk-H6s9Bhq28s5YRIkHid163c-yqpeY8U5j9U70aveSuEcLz-UMlgsQ8MaYhHIIv7cJpag2RJFAgGxOZnWONEk2Z9-IK_Ea_4

recaptcha v3回复:

{
"score":0.1,
"hostname":"localhost",
"success":true,
"challenge_ts":"2018-07-17T21:24:03Z",
"action":"AW___________LGOZCKiH_oQBEJnwwYcD"
}
Run Code Online (Sandbox Code Playgroud)

同一页面上具有相同标签的第二个令牌:

03AEMEkEk-CVItfMmzYErG97inmxzf7mIeWuAgEXmwncu8AvMGP0ofXnwCMFNdBpa7CY8MCkVZ_skiF1HwmGhKBgayFm-fM3VM_QfM5LRNDbxLLyCF8lGclmBBlihmkeT1PsvW9LrVfp2VdikuHxeqvviGnI2NKQHbclvaDnuu5rwy3HS_EiPrn7eJb3z892f8oIOMkVg6tTsCNPCTnH5QuvAIw2DlI3EiRFDSqIjXp4vJdzJIGn10K6Noi1JIPOCzJ8OUshn_yFROWvNNpYNFn3E7tSHk3j0LU9-KDy1RiSoEf2I1VcVEKTE

recaptcha v3回复:

 {"error-codes":["timeout-or-duplicate"],"success":false}
Run Code Online (Sandbox Code Playgroud)

recaptcha recaptcha-v3

6
推荐指数
1
解决办法
2128
查看次数

在没有 postcss 的情况下安装 react-scripts

我正在尝试将我的代码上传到服务器上,但由于存在中等漏洞,它不允许我这样做。我已经将我的问题缩小到从安装 react 应用程序下载的旧版本 postcss,特别是 react-scripts。我试过卸载 postcssreact-scripts然后postcss先安装,但是每当我进行安装时,它都会在其对node-modules文件夹的依赖项中安装一个错误的版本。

记录一些错误,以防我的问题没有 postcss

 Moderate        Regular Expression Denial of Service                          
  Package         postcss                                                       
  Patched in      >=8.2.10                                                      
  Dependency of   react-scripts                                                 
  Path            react-scripts > postcss-preset-env > postcss-place > postcss  
  More info       https://npmjs.com/advisories/1693                             

  Moderate        Regular Expression Denial of Service                          
  Package         postcss                                                       
  Patched in      >=8.2.10                                                      
  Dependency of   react-scripts                                                 
  Path            react-scripts > postcss-preset-env >                          
                  postcss-pseudo-class-any-link > postcss                       
  More info       https://npmjs.com/advisories/1693                             

  Moderate        Regular Expression Denial of Service                          
  Package         postcss                                                       
  Patched in      >=8.2.10                                                      
  Dependency of   react-scripts                                                 
  Path            react-scripts …
Run Code Online (Sandbox Code Playgroud)

node.js reactjs postcss

6
推荐指数
1
解决办法
1000
查看次数

保护"默认"方法不要覆盖

我正在寻找一种解决方案,它允许保护默认方法免于继承.最简单的解决方案可能是 - 从课堂等延伸......但在我的情况下,这是不可能的.

有人可以建议如何解决这个问题吗?可以有任何解决方法吗?

Atm我有以下代码,需要重新编写(如果/任何可能):

public interface MyInterface1 {
    default boolean isA(Object obj) {
         return (boolean) obj.equals("A") ? true : false;
    }

    default boolean isB(Object obj) {
         return (boolean) obj.equals("B") ? true : false;
    }
}

public class MyClass extends MyLogic implements MyInterface, MyInterface1 {
// this class allows to inherit methods from both interfaces,
// but from my perspective i'd like to use the methods from MyInterface1 as it is,
// with a 'protection' from inheritance. is that possible? …
Run Code Online (Sandbox Code Playgroud)

java java-8

5
推荐指数
2
解决办法
1100
查看次数

自动连接的依赖项注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:

我在这里是新手,我正在尝试使用Spring创建一个电子商店,但与数据库的连接存在问题。我搜索发现其他用户也问过同样的问题,但我找不到问题。我缺乏想法,这是怎么了。

堆栈跟踪:

org.springframework.beans.factory.BeanCreationException:创建名称为'homeController'的bean时出错:自动连接依赖项的注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有dao.ProductDao controllers.HomeController.productDao; 嵌套的异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有找到类型为[dao.ProductDao]的合格Bean作为依赖项:至少应有1个有资格作为此依赖项的自动装配候选的bean。依赖项注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}

源代码:

控制者

package controllers;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import dao.ProductDao;
import model.Product;

@Controller
public class HomeController {

@Autowired
private ProductDao productDao;

@RequestMapping("/")
public String home(){
    return "home";
}

@RequestMapping("/productList")
public String getProducts(Model model) {
    List<Product> products = productDao.getAllProducts();
    model.addAttribute("products", products);

    return "productList";
}

@RequestMapping("/productList/viewProduct/{productId}")
public String viewProduct(@PathVariable String productId, Model model) throws IOException{

    Product product = productDao.getProductById(productId);
    model.addAttribute(product);
    return "viewProduct";
}
Run Code Online (Sandbox Code Playgroud)

} …

java spring hibernate spring-mvc maven

5
推荐指数
1
解决办法
8979
查看次数

无法在网络浏览器中打开 SonarQube

我正在尝试集成 SonarQube 和 Jenkins,为此我已在远程Vagrant VM(Ubuntu 14.04 LTS)上安装了这两个工具。一切工作正常,当我在 Jenkins 中运行 SonarQube 分析时构建成功,但我无法http://<myipaddress>:port从 Windows(本地)计算机打开 Sonar 仪表板。当 Jenkins 中构建成功时,它会给我一个 URL 以便浏览分析报告,但这个 URL 给了我ERR_CONNECTION_TIMED_OUT.

到目前为止我尝试过的选项:

  1. 尝试禁用 Ubuntu 防火墙
  2. 当我从 Windows 执行 Tracert 时,它显示“目标主机无法访问”。
  3. 当我尝试从 Windows 计算机 ping 远程计算机时,出现请求超时错误。
  4. 尝试检查声纳日志,没有显示任何错误。

我也尝试了其他选择,但似乎都不起作用。如果有人能指导我完成这个任务,那将会有很大的帮助。我不太清楚如何通过网络浏览器在本地计算机中打开 SonarQube 的仪表板,而它已安装在远程计算机上。先感谢您!

jenkins sonarqube

5
推荐指数
1
解决办法
2392
查看次数

使用闪亮的动态CheckboxGroupInput

我正在尝试创建一个复选框,以便能够按年份过滤数据集。然而,并非每个变量都具有每年的所有数据,因此我只想要变量具有用户界面中显示的数据的年份。遗憾的是,将我的代码拆分为条件面板后,按钮不再进行过滤。

conditionalPanel(condition = "input.Select2 == 'AFD' | input.Select2 == 'Piraten'",
                           checkboxGroupInput("Year", label = h3("Checkbox group"), 
                                              choices =  "2013"),
                                              selected = "2013"),
         conditionalPanel(condition = "input.Select2 == 'DieLinke'",
                         checkboxGroupInput("Year", label = h3("Checkbox group"), 
                                            choices = list("2009", "2013"),
                                            selected = "2013")),
        conditionalPanel(condition = "input.Select2 == 'Gruene' | input.Select2 == 'FDP' | input.Select2 == 'SPD' | input.Select2 == 'CDU'",
                         checkboxGroupInput("Year", label = h3("Checkbox group"), 
                                            choices = list("1998", "2002", "2005","2009", "2013"),
       selected = "2013"))
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么?

这是在服务器函数中生成的绘图的示例:

dfParteien %>%
                                                filter(Partei %in% chosen_party) %>% 
                                                filter(Jahr %in% input$Year) …
Run Code Online (Sandbox Code Playgroud)

checkbox user-interface r dynamic shiny

4
推荐指数
1
解决办法
5295
查看次数

在应用程序启动时执行多个脚本

我将DataSource定义为bean:

@Bean(name="dataSource")
public DriverManagerDataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.h2.Driver");
    dataSource.setUrl("jdbc:h2:~/myDB");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
}
Run Code Online (Sandbox Code Playgroud)

它工作完美,但是我需要为数据库创建指定模式并在其上加载数据。是否有机会像Spring Data一样执行两个脚本(模式脚本和数据脚本)?我发现的唯一的东西是datasource.setSchema(),以及我所担心的,我必须指定它的完整路径。如果我的模式脚本位于src/main/resources/路径中,那么如何指定它呢?(我确实做了,文档怎么说,但失败并显示一条消息)

发生意外错误(类型=内部服务器错误,状态= 500)。org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取JDBC连接。嵌套的异常是org.h2.jdbc.JdbcSQLException:找不到架构“〜/ schema-h2.sql” [90079-193]

谢谢你的建议

java spring jdbc spring-jdbc

3
推荐指数
2
解决办法
3849
查看次数

无法解构“节点”的属性“名称”,因为它为空

当我想安装 aurelia 项目的依赖项时,出现此错误:

npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /Users/ehsanghaffarii/.nvm/versions/node/v15.5.1/bin/node /Users/ehsanghaffarii/.nvm/versions/node/v15.5.1/lib/node_modules/npm/bin/npm-cli.js install --cache=/Users/ehsanghaffarii/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
npm ERR! npm ERR! code ERESOLVE
npm ERR! npm ERR! Cannot destructure property 'name' of 'node' as it is null.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/ehsanghaffarii/.npm/_cacache/_logs/2021-01-14T17_17_22_767Z-debug.log

npm ERR! A complete log of this run can be found in:
npm …
Run Code Online (Sandbox Code Playgroud)

node.js npm aurelia

3
推荐指数
1
解决办法
2万
查看次数

配置嵌入式MongoDB的最简单方法

我想知道,有没有如何正确配置嵌入式任何例如MongoDBSpring Boot

例如,这就是我配置H2嵌入式数据库的方式:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.jndi.JndiObjectFactoryBean;

import javax.sql.DataSource;


@Configuration
@PropertySource({"configs/datasource.properties"})
public class DataSourceConfig {

    @Bean
    @Profile("test")
    public DataSource testDataSource() {
        return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
    }
}
Run Code Online (Sandbox Code Playgroud)

这很好用,但是有一个问题。这种方法不提供MongoDB的配置。

有什么解决方法吗?

更新1:

[错误]无法在项目XXX上执行目标org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE:run(default-cli):运行时发生异常。null:InvocationTargetException:创建在类路径资源[com / reborn / XXX / config / DataSourceConfig .class]中定义的名称为'mongoTemplate'的bean时出错:通过工厂方法的Bean实例化失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframewor k.data.mongodb.core.MongoTemplate]:工厂方法“ mongoTemplate”抛出了异常;嵌套的异常是java.lang.NoClassDefFoundError:de / flapdoodle / embed / mongo / distribution / IFeatureAwareVersion:de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion-> [帮助1]

更新2:

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> …
Run Code Online (Sandbox Code Playgroud)

java spring mongodb spring-boot

2
推荐指数
1
解决办法
5111
查看次数

如何将 useQuery 作为异步任务调用

我是React Native和 的新手Apollo-Client。在我的屏幕中有三个选项卡,各个选项卡正在调用自己的数据。但是由于useQuery用户界面完全冻结并提供非常糟糕的体验。

有没有其他方法可以useQuery以异步方式或在任何后台任务中调用?

编辑

function PlayerList(props) {

    const [loading , setloading] = useState(true)
    const [data, setData] = useState()
    const [loadData, { tempLoading, tempError, tempData }] = useLazyQuery(query);
   

   async function getData(){
        loadData()
   }

    useEffect(() => {

        if (tempData == undefined) {
            getData()
        }

    })

     if(tempLoading){
           return 
                <View >....</View>
     }
     if(tempData) {
          return ( <View> ... </View>) }

 }
Run Code Online (Sandbox Code Playgroud)

请找到上面的代码以便更好地理解。

apollo graphql react-native apollo-client react-hooks

2
推荐指数
1
解决办法
6549
查看次数