我想在我的Java类中调用Javascript但是找不到正确的方法.我在某处可以看到它可以使用Nashorn完成.有人可以让我知道确切的方式.
我正在尝试创建 FindByIndexNameSessionRepository 的 Bean。我需要让所有用户会话都使用它,但即使我已经定义了它,我也会收到 bean 错误。我正在使用 Spring Boot Starter 1.5.7
错误:字段 sessionRepository 需要一个无法找到的“org.springframework.session.FindByIndexNameSessionRepository”类型的 bean。
考虑在您的配置中定义一个 'org.springframework.session.FindByIndexNameSessionRepository' 类型的 bean。
我正在尝试创建 bean 并在我的配置中使用它,如下所示:
import com.x.security.SpringSessionBackedSessionRegistry;
@Bean
SpringSessionBackedSessionRegistry sessionRegistry() {
return new SpringSessionBackedSessionRegistry<ExpiringSession>(
this.sessionRepository);
}
@Autowired
private FindByIndexNameSessionRepository<ExpiringSession> sessionRepository;
Run Code Online (Sandbox Code Playgroud)
我的配置如下
http<...>
.maximumSessions(2)
.sessionRegistry(sessionRegistry())
.maxSessionsPreventsLogin(false)
.<other settings>
Run Code Online (Sandbox Code Playgroud)
我的 SpringSessionBackedSessionRegistry 类如下:
public class SpringSessionBackedSessionRegistry<S extends ExpiringSession>
implements SessionRegistry {
private final FindByIndexNameSessionRepository<S> sessionRepository;
public SpringSessionBackedSessionRegistry(
FindByIndexNameSessionRepository<S> sessionRepository) {
Assert.notNull(sessionRepository, "sessionRepository cannot be null");
this.sessionRepository = sessionRepository;
}
@Override
public List<Object> getAllPrincipals() {
throw new …Run Code Online (Sandbox Code Playgroud) 背景:我正在一个名为 的项目中工作com.x.myproject。我有另外两个包的依赖关系com.x.document和com.x.library. 两个包都有相同的类,名称为QueueHelper。
现在,在我的项目中,我必须扫描另一个com.x.security内部扫描的包com.x,如下所示:
@SpringBootApplication
@ComponentScan(basePackages = {"com.x"})
@EnableCaching
public class Security {
.......
}
Run Code Online (Sandbox Code Playgroud)
在 com.x.myproject 中
@SpringBootApplication
@ComponentScan(basePackages = {"com.x.myproject","com.x.security"}, excludeFilters={
@ComponentScan.Filter(type=FilterType.REGEX, pattern="com.x.document.*"),
@ComponentScan.Filter(type=FilterType.REGEX, pattern="com.x.library.*")})
public class MyProject{
.......
}
Run Code Online (Sandbox Code Playgroud)
excludefilters当我使用时一切正常,com.x.security但我想使用它com.x.myproject
我得到的例外是
Annotation-specified bean name 'queueHelper' for bean class [com.x.library.utils.QueueHelper] conflicts with existing, non-compatible bean definition of same name and class [com.x.document.utils.QueueHelper]
Run Code Online (Sandbox Code Playgroud)