我有自定义身份验证筛选器,它创建PreAuthenticatedAuthenticationToken
并将其存储在安全上下文中 一切正常.这是配置:
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SsoAuthenticationProvider authenticationProvider;
@Autowired
private SsoAuthenticationFilter ssoAuthenticationFilter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(ssoAuthenticationFilter, SecurityContextPersistenceFilter.class);
}
}
Run Code Online (Sandbox Code Playgroud)
现在我ssoAuthenticationFilter
是FilterChainProxy
正确位置的一部分.平滑.
但由于ssoAuthenticationFilter
是Filter
它得到通过引导拾起并作为过滤器.所以我的滤镜链看起来像:
Filter
)http.addFilterAfter(...)
)显然我想摆脱ssoAuthenticationFilter
这里的自动注册(列出的第一个).
任何提示非常感谢.
我有使用Hibernate的Web界面(Spring MVC)的java应用程序.我在这里有一个非常简单的数据库方案,有一个可以在一个网页上添加/删除的组实体.然后有另一个实体将Group作为字段,因此实体具有FK到Group.请注意,通常可能有许多其他实体引用我的组.
如果我想删除Group对象,它可能会在FK约束上失败 - 该组由其他实体引用.
有没有办法如何执行检查我的组被引用,删除将失败而不是执行删除和捕获异常?这里的最佳做法是什么?
谢谢
注意:为了清楚起见,简单的选择不是解决方案,因为该组可能被许多其他表格引用,而不仅仅是一个.
我有一个KDB/Q数据库,每天大约有2M的记录消耗大约2G的内存.在一天结束时,它会运行一些报表,在表之间进行连接并将结果输出到磁盘上的文件中.在计算过程中,内存使用量增长到~15G.我的问题是,一旦此操作完成,内存永远不会被释放,直到DB重新启动它消耗所有15G的内存.
我想告诉KDB从内存中卸载一些表(虽然不要删除它们)但是我不想重新启动数据库,因为其他一些应用程序仍在连接它.
有没有办法告诉KDB从内存中卸载一些东西?
编辑:
如果有人发现它有趣我建议看看.Q.gc[]
KDB 2.5+,看起来很有希望.
我有弹簧启动应用程序(1.1.5.RELEASE)并通过配置属性启用我的配置文件spring.profiles.active=MyProfile
配置文件被正确激活,我可以从正在创建的配置文件中看到bean.
然后我@Controller
用了如下:
@Controller
@RequestMapping("/someUrl")
@Profile("MyProfile")
public class MyController {
...
}
Run Code Online (Sandbox Code Playgroud)
未实例化此控制器,并且未映射控制器中使用的URL.在同一个包中,我有另一个不受限制的控制器,@Profile
这些控制器按预期进行实例化和映射.
那么@Profile
在控制器上使用与弹簧启动不兼容的东西吗?我应该使用其他方法吗?
编辑:这似乎是一个错误,好像我-Dspring.profiles.active=MyProfile
作为JVM属性包含控制器实例化:'(
编辑2:所以这里有趣的部分:
如果定义spring.profiles.active
在application.properties
其默认情况下,从classpath中加载thne它的工作原理
当您重命名文件test.properties
并通过@PropertySource("classpath:test.properties")
它包含它停止工作.会针对它提出一个错误.
编辑3:按照承诺:https://github.com/spring-projects/spring-boot/issues/1417
谢谢!
我有以下Guice模块:
class MyModule extends AbstractModule {
@Override
protected void configure() {
bindListener(Matchers.any(), new TypeListener() {...});
}
@Provides
SomeClass createSomeClass(final Parameter param) {
log(param.getValue()); <-- this gets logged
...
}
}
Run Code Online (Sandbox Code Playgroud)
我发现奇怪的是我TypeListener
没有得到有关Parameter
类型的通知.即使提供者被称为并且返回SomeClass
.我也很清楚地看到日志声明Parameter
是由Guice注入的.
@Override
protected void configure() {
bind(Parameter.class);
bindListener(Matchers.any(), new TypeListener() {...});
}
Run Code Online (Sandbox Code Playgroud)
我知道Untargetted绑定和声明:
无标记的绑定通知注入器有关类型的信息,因此可能会急切地准备依赖关系.
我仍然希望Guice能够为第一次TypeListener
明确绑定或注入的任何类型调用.
那么我是否需要根据经验对这些类进行无限制的绑定?
注意:标记Parameter
构造函数@Inject
不能解决问题.
编辑:
完整的例子(希望我不要留下太多的垃圾)如下:
public class TestGuice {
public static void main(String[] args) { …
Run Code Online (Sandbox Code Playgroud) 春天的时候我这样做:
@Autowire
List<MyInterface> myInterfaces;
Run Code Online (Sandbox Code Playgroud)
然后这个列表将被所有实现的bean填充MyInterface
.我没有创建类型的bean List<MyInterface>
.
我在Google Guice中寻找此类行为.
Sofar我去了:
Multibinder<MyInterface> myInterfaceBinder = MultiBinder.newSetBinder(binder(), MyInterface.class);
Run Code Online (Sandbox Code Playgroud)
现在如果我有一个实现MyInterface
并绑定它的bean ,请通过:
bind(MyInterfaceImpl.class).asEagerSingleton();
Run Code Online (Sandbox Code Playgroud)
它不会包含在我的multibinder中.我需要添加:
myInterfaceBinder.addBinding.to(MyInterfaceImpl.class);
Run Code Online (Sandbox Code Playgroud)
这比Spring提供的要复杂一些.所以我很惊讶我是不是以错误的方式使用它.那么有更简单的方法来实现这一目标吗?
我有一个Web应用程序,我在Windows和Linux环境中运行.在Linux和只有 Linux我得到以下异常:
Caused by:
java.lang.IllegalArgumentException: Invalid embedded descriptor for "moop_shared.proto".
at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:301)
...
Caused by:
com.google.protobuf.Descriptors$DescriptorValidationException: moop_shared.proto: Dependencies passed to FileDescriptor.buildFrom() don't match those listed in the FileDescriptorProto.
at com.google.protobuf.Descriptors$FileDescriptor.buildFrom(Descriptors.java:246)
at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:299)
...
Run Code Online (Sandbox Code Playgroud)
所以我在本地和远程调试它比较结果.我无法理解以下内容:
ENV:
protobuf的-Java的2.5.0
java 7
在这两种情况下,我运行相同的webapp,我在代码中的相同位置,这是com.google.protobuf.Descriptors.java#245
看代码
对于上下文
...
for (int i = 0; i < proto.getDependencyCount(); i++) {
HERE --> if (!dependencies[i].getName().equals(proto.getDependency(i))) {
throw new DescriptorValidationException(result,
"Dependencies passed to FileDescriptor.buildFrom() don't match " +
"those listed in the FileDescriptorProto.");
}
}
...
Run Code Online (Sandbox Code Playgroud)
以下是来自调试器的信息:
视窗: …
我有一个.proto
需要导入的文件定义,"google/protobuf/descriptor.proto"
因为我使用自定义选项.
所以在我的.proto
文件中我做了:
import "google/protobuf/descriptor.proto";
package ...;
...
Run Code Online (Sandbox Code Playgroud)
由于我的文件没有编译抱怨依赖项,我得到了一个descriptor.proto文件的副本,将它放在我的proto文件所在的目录中.
这解决了问题,但我不相信这是正确的方法.现在将descriptor.proto
gets与我的.proto
文件一起编译descriptor.proto
,导致在运行时编译2 :
protobuf-java-2.5.0.jar
文件一起提供的那个.proto
文件一起编译的那个我认为--proto-path
应该以某种方式使用该选项,但不完全确定什么是正确的方法.
感谢这里的最佳实践提示!
我正在使用spring boot(截至目前为1.2.1),我需要增加默认的8k请求头大小限制,该限制存在HttpConfiguration
于Jetty的类中.看看JettyEmbeddedServletContainerFactory
哪些我可以掌握,EmbeddedServletContainerCustomizer
但无法看到如何改变它的方式.
我也确实看了一下JettyServerCustomizer
- 我明白我可以Server
通过它再次抓住码头- 没办法怎么改变HttpConfiguration
这里.
任何提示将不胜感激.
我想在处理spring数据休息时寻求应用业务规则的最佳实践.
让我们考虑以下场景:
Customer
和Order
中@OneToMany
关系.Customer
需要验证标志设置为能够下订单所以,我需要确保每当有人POST
s到/orders
了Customer
使呼叫验证.
我正在考虑使用beforeSave Validators自动装配其他服务/存储库Validator
并检查需要检查的内容.
是否有更好的方法来实现同样的目标?