是否有与JPA @Column注释等效的SpringData Mongo?
基本上,我有一个POJO,其中包含一个我希望以不同名称存储在Mongo中的属性.那么,以下对象:
public class Pojo{
@Property("bar")
private String foo = "Hello World";
}
Run Code Online (Sandbox Code Playgroud)
会被坚持为:
{
"_class":"com.example.Pojo",
"bar" : "Hello World"
}
Run Code Online (Sandbox Code Playgroud)
注意:我不想使用MappingMongoConverter明确地执行它
我们正在重新设计我们的产品以删除SpringSecurity中的默认"anonymousUser"行为,并希望锁定所有URL(通过过滤器安全性),只有几个端点除外.我们无法弄清楚的是如何指定"锁定除X,Y和Z之外的所有东西"
我们的安全设置基本上归结为以下内容:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// disable anonymous users
.anonymous().disable()
// don't add ROLE_ to the role...
.authorizeRequests()
.regexMatchers("^/", "^/login", "^/mobile/login", "^/api/auth/.*")
.authenticated()
.and()
;
}
}
Run Code Online (Sandbox Code Playgroud)
我采取的其他路线类似于:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// disable anonymous users
.anonymous().disable()
// don't add ROLE_ to the role...
.authorizeRequests()
.antMatchers("/**")
.authenticated()
.antMatchers("/", "/login", "/mobile/login", "/api/auth/**", "/reservations/**")
.permitAll()
.and()
; …Run Code Online (Sandbox Code Playgroud) 我正试图找出使用Spring Cloud和Netflix堆栈构建和实现微服务的最佳方法,特别是使用Eureka和Feign.我有几个与安全相关的问题:
我已经看到您可以使用用户名/密码凭据配置Eureka Server.这可以防止未经授权的应用程序,但随后每个应用程序必须共享凭据才能访问Eureka.是否有一种简单的方法来创建凭证注册表,以便每个微服务都可以拥有它?(将它挂钩到Spring Security的堆栈中会很好 - UserDetailService等等)
一旦微服务接线并通过假装进行通信,是否可以将原始请求上使用的凭证共享/传递给对其他微服务进行的其他调用?因此,如果"Jim"请求/foos对FooService和BarService/bars上的FooService请求,BarService会知道是Jim请求它们吗?
Jim> FooService> BarService - BarService知道正在为Jim处理请求...
我正在为一组Spring Cloud + Netflix OSS应用程序进行原型设计,并且遇到了Eureka的问题.在我们的设置中,我们有一个Spring Cloud Config Server + Eureka Server,然后是2个模块,它们利用该服务器组件进行自举和服务发现.
我遇到的问题是,如果我旋转起来尤里卡服务器的两个实例,并尝试将二者进行配对(基于两个对等感知尤里卡服务器中的文档),他们不相互同步.请参阅下面的配置和/或GitHub上的代码.
从本质上讲,Peer1启动并且看起来很好.Peer2将启动并且看起来很好,两个同行在服务中互相展示.但是,如果"UserService"模块旋转并向Peer1注册自身,Peer2将永远不会看到它.如果我们然后启动指向Peer2的"Web"模块,它就永远无法解析UserService.他们基本上是孤立地行事.
我已尝试过serviceUrl在服务器和Eureka服务器实例上设置两者的几种组合,但无济于事.我只是配错了吗?
对等1 /默认配置:
server:
port: 8888
eureka:
dashboard:
path: /dashboard
instance:
hostname: peer1
leaseRenewalIntervalInSeconds: 3
client:
serviceUrl:
defaultZone: ${eureka.server.serviceUrl:http://localhost:${server.port}/eureka/}
server:
serviceUrl:
defaultZone: http://localhost:${server.port}/eureka/
peer2: http://peer2/eureka/
waitTimeInMsWhenSyncEmpty: 0
spring:
application:
name: demo-config-service
profiles:
active: native
# required for Spring Cloud Bus
rabbitmq:
host: ${DOCKER_IP:192.168.59.103}
port: 5672
username: guest
password: guest
virtualHost: /
cloud:
config:
server:
prefix: /configs
native:
searchLocations: /Users/dave/workspace/oss/distributed-spring/modules/config-server/src/main/resources/testConfigs …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 BitBucket 私有存储库设置 Spring Cloud 的配置服务器,但没有任何运气。无论我使用什么配置,在尝试加载配置时似乎总是返回 404。
我也尝试过在 中设置断点JGitEnvironmentRepository,但似乎从未在afterPropertiesSet. 如果我在调试时手动触发findOne(application,profile,label),则会收到错误消息Branch name <null> not allowed。如果我为属性指定“master” label,那么我会收到可怕的Ref master cannot be resolved错误。
该应用程序加载正常,但没有结果。从我读过的所有文档来看,这似乎应该是开箱即用的。任何帮助,将不胜感激。
bootstrap.yml
server:
port: 8888
spring:
application:
name: config-service
cloud:
bus.amqp.enabled: false
config:
enabled: false
failFast: true
server:
prefix: /configs
git :
uri: https://bitbucket.org/[team]/[repo].git
username: [user]
password: [pass]
Run Code Online (Sandbox Code Playgroud)
回购文件
- demo.app.yml
Run Code Online (Sandbox Code Playgroud)
尝试的网址
我正在编写一个简单的脚本和插件,将"暂存"Wordpress站点移动到生产站点.方法很简单:mysql dump,检查所有内容到源代码控制,调整数据库名称,在生产中恢复.
我遇到的一个问题是我无法弄清楚如何在设置>阅读下切换搜索引擎可见性设置.我希望搜索引擎可以忽略分段,但不会覆盖生产中的设置(恢复后).
关于如何做到这一点的任何想法?快速和脏(在sql转储文件上使用sed/find和replace等)对我来说很好.
谢谢
我似乎无法访问我的Mac上本地运行的简单Docker容器.我可以curl localhost从容器中运行并看到默认的Apache页面已经提供,但我无法从我的机器的浏览器中点击它.
我想知道我是否有VirtualBox配置问题.有没有帮助诊断问题?
# Build the image of ubuntu 12.04 LTS
from ubuntu:precise
# Run apt-get update
run apt-get -y update
# Install LAMP
run DEBIAN_FRONTEND=noninteractive apt-get -y install lamp-server^
run apt-get -y install vim-tiny curl wget
# Put custom scripts in the container and give proper permissions to them
add ./startup.sh /usr/local/bin/startup.sh
run chmod 755 /usr/local/bin/startup.sh
add site.vhost /etc/apache2/sites-available/site
run a2ensite site
# Expose port 80 to the host machine
expose 80
Run Code Online (Sandbox Code Playgroud)
<VirtualHost *:80>
ServerAdmin …Run Code Online (Sandbox Code Playgroud) 我已经使用Keychain Access导入了多个域的自签名证书(比方说my.foo.bar.com和yours.foo.bar.com),但Chrome仍然不接受它,提示我每个域的每个浏览会话开始时进行验证.
证书是使用x509v3 主题备用名称扩展名生成的,以验证多个域.如果我在导入证书之前导航到该站点,我会收到与导入后不同的警告消息.下面附有两个错误的图像(顶部是导入前的错误)

有没有办法接受自签名的多域证书?我只在Chrome中收到警告,顺便说一下.FF和Safari工作得很好(除了那些浏览器很糟糕;))
更新:我尝试使用openssl cli和xca GUI 生成证书
我有一个Angular.js指令,我正在编写以减少Twitter Bootstrap的一些样板.到目前为止,我已经创建了一个form-input元素,它按预期显示.但是,如果我将许多这些指令放在同一个父元素中,那么实际只会添加第一个指令并显示出来.
任何人都可以解释为什么?
我的加价:
<form class="form-horizontal" role="form">
<form-input type="text" target="name1" label="Name1" placeholder="Doug" ng-model="name1"/>
<form-input type="text" target="name2" label="Name2" placeholder="Frank" ng-model="name2"/>
</form>
Run Code Online (Sandbox Code Playgroud)
app.js
var app = angular.module('app', ['ui.router']);
app.controller('FormInputController', ['$scope', '$attrs', function($scope, $attrs){
console.log("Controller");
}]);
app.directive('formInput', function(){
return {
restrict: 'E',
controller: 'FormInputController',
transclude: true,
replace: true,
require: ['^ngModel'],
template: '<div class="form-group">'
+ '<label for="{{id}}" class="col-sm-2 control-label">{{label}}</label>'
+ '<div class="col-sm-10">'
+ '<input type="{{type}}" class="form-control" id="{{id}}" placeholder="{{placeholder}}">'
+ '</div>'
+ '</div>',
scope: {
id: '@',
label: '@',
placeholder: '@',
type: "@" …Run Code Online (Sandbox Code Playgroud) spring ×3
spring-cloud ×3
java ×2
angularjs ×1
certificate ×1
docker ×1
git ×1
javascript ×1
lamp ×1
mongodb ×1
mysql ×1
netflix ×1
php ×1
self-signed ×1
spring-data ×1
ssl ×1
wordpress ×1