小编Mon*_*mul的帖子

Hashset与Treeset

我一直喜欢树木,它们很好,O(n*log(n))而且它们整洁.然而,我所知道的每一位软件工程师都有针对性地问我为什么会使用TreeSet.从CS背景来看,我认为你所使用的并不重要,而且我不想乱用哈希函数和桶(在这种情况下Java).

在这情况下,我应该使用HashSetTreeSet

java hashset treeset

482
推荐指数
8
解决办法
30万
查看次数

Spring Security在登录后总是返回403 accessDeniedPage

我是Spring的新手,我一直在尝试使用spring security实现一个简单的登录页面.但它总是在提供登录凭据后访问Denied url.在我提供正确的用户名和密码后,loadUserByUsername()方法始终返回用户.但我不知道如何找到返回用户对象后发生的事情.

用户只有一个角色.该方法返回具有SUPER_USER角色的用户.

这是我的spring安全配置类

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.authentication.AuthenticationTrustResolverImpl;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = AppConfig.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    UserDetailsService userDetailsService;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {

        System.out.println("Inside configureGlobalSecurity method");

        auth.userDetailsService(userDetailsService);
        auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        System.out.println("Inside configure method");
        http.authorizeRequests().antMatchers("/", "/list")
                .access("hasRole('SUPER_USER') or hasRole('NORMAL_USER') or hasRole('CUSTOMER')")
                .and().formLogin().loginPage("/login") …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-security

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

如何删除 Quartz JDBC Store 中的作业?

我编写了这个方法来从 Quartz JDBC 中删除作业

public boolean removeJob(String jobName) {
    try {
        JobKey jobKey = JobKey.jobKey(jobName);  
        try {    
            Scheduler sched = schedulerFactoryBean.getScheduler();  
            logger.info("RESULT: " + sched.deleteJob(jobKey)); 
        } catch (Exception e) {    
            throw new RuntimeException(e);    
        }    
        return true; 
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        return false; 
    } 
} 
Run Code Online (Sandbox Code Playgroud)

deleteJob总是会回来false。因此该作业不会从 mysql 的 JDBC 表中删除。我究竟做错了什么。我只想从调度程序中完全删除此作业

java spring quartz-scheduler

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

错误:包 org.apache.commons.collections15 不存在

我想运行一个java 包来测量我的社区检测算法的质量,但我遇到以下错误:

Standalone.java:22: error: package org.apache.commons.collections15 does not exist 
Run Code Online (Sandbox Code Playgroud)

似乎该软件包并未默认安装在 java 中,因为我已经使用 sudo apt-get install default-jdk类似的命令安装了 java 。我在https://github.com/cloudera/collections-generic 中找到了包含集合 15的包。Java 不是我的编程语言,我不知道如何安装包;我应该把它放在特定的文件夹中吗?

java collections

0
推荐指数
1
解决办法
7377
查看次数