我正在关注Dave Syer的基本Spring Boot OAuth2示例:https://github.com/dsyer/sparklr-boot/blob/master/src/main/java/demo/Application.java
@Configuration
@ComponentScan
@EnableAutoConfiguration
@RestController
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    @RequestMapping("/")
    public String home() {
        return "Hello World";
    }
    @Configuration
    @EnableResourceServer
    protected static class ResourceServer extends ResourceServerConfigurerAdapter {
        @Override
        public void configure(HttpSecurity http) throws Exception {
            // @formatter:off
            http
                // Just for laughs, apply OAuth protection to only 2 resources
                .requestMatchers().antMatchers("/","/admin/beans").and()
                .authorizeRequests()
                .anyRequest().access("#oauth2.hasScope('read')");
            // @formatter:on
        }
        @Override
        public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
            resources.resourceId("sparklr");
        } …java spring spring-security spring-boot spring-security-oauth2
我希望能够对每个项目POM执行分析,以确定每个直接依赖项基于其所有传递依赖项的总和引入到生成的包中的字节数.
例如,如果依赖关系A带来B,C和D,我希望能够看到显示A - >总大小=(A + B + C + D)的摘要.
是否存在Maven或Gradle方法来确定此信息?
我正在使用Vagrant处理几个用例,并且很难找到一个以优雅方式处理公司代理的良好解决方案.在我最初的Vagrantfile中,我最终得到了apt.conf的配置
user = 'me'
pwd = 'mypwd'    
config.vm.provision :shell, :inline => "echo 'Acquire::http::Proxy \"http://#{user}:#{pwd}@proxy.corp.com:3210\";' >> /etc/apt/apt.conf"
config.vm.provision :shell, :inline => "echo 'Acquire::https::Proxy \"http://#{user}:#{pwd}@proxy.corp.com:3210\";' >> /etc/apt/apt.conf"
config.vm.provision :shell, :inline => "echo 'Acquire::socks::Proxy \"http://#{user}:#{pwd}@proxy.corp.com:3128\";' >> /etc/apt/apt.conf"
显然,我想避免将我的用户/密码存储在Vagrantfile中,因为我计划将其保留在版本控制之下.我的下一次尝试是使用highline插件从Vagrantfile中提示,但这会导致在每个vagrant命令期间出现提示,而不仅仅是在init期间(当此配置适用时).
我是以错误的方式来做这件事的吗?如果是这样,还有哪些其他选项可用于处理适合Vagrant模型的代理配置?
我正在从FindBugs(2.0.2)和Sonar(3.7.3)得到我认为是通过静态编织EclipseLink(2.5.1)JPA实体生成的代码的误报.具体来说,我看到多次出现
ES_COMPARING_PARAMETER_STRING_WITH_EQ
Comparison of String parameter using == or != in com.test.domain.MyEntity._persistence_set(String, Object)
和
URV_INHERITED_METHOD_WITH_RELATED_TYPES
Inherited method com.test.domain.MyEntity._persistence_get(String) returns more specific type of object than declared
有没有办法消除EclipseLink生成的代码的这些警告,而不必全局禁用规则或完全排除对实体的分析?
我无法弄清楚如何使用@RepositoryRestResource接口在两个相当简单的实体之间创建多对多关系.
例如,我有一个简单的父子实体关系,如下所示:
@Entity
public class ParentEntity {
    @Id
    @GeneratedValue
    private Long id;
   @ManyToMany
   private List<ChildEntity> children;
}
@Entity
public class ChildEntity {
    @Id
    @GeneratedValue
    private Long id;
    @ManyToMany(mappedBy="children")
    private List<ParentEntity> parents;
}
我的存储库正在使用vanilla Spring @RepositoryRestResource HATEOS API:
@RepositoryRestResource(collectionResourceRel = "parents", path = "parents")
public interface ParentRepository extends PagingAndSortingRepository<ParentEntity, Long> {
}
@RepositoryRestResource(collectionResourceRel = "children", path = "children")
public interface ChildRepository extends PagingAndSortingRepository<ChildEntity, Long> {
}
我已成功使用POST来创建单独的ParentEntity和ChildEntity,但我似乎无法弄清楚如何使用内置接口PUT/PATCH两者之间的关系.
看起来我应该能够使用PUT将JSON发送到类似的东西http://localhost:8080/api/parents/1/children,但到目前为止,我找不到一个有效的结构.
我使用groovy RESTClient 0.6来发出POST请求.我希望响应中有一个XML有效负载.我有以下代码:
def restclient = new RESTClient('<some URL>')
def headers= ["Content-Type": "application/xml"]
def body= getClass().getResource("/new_resource.xml").text
/*
 If I omit the closure from the following line of code
 RESTClient blows up with an NPE..BUG?
*/
def response = restclient.post(
                            path:'/myresource', headers:headers, body:body){it}
 println response.status //prints correct response code
 println response.headers['Content-Length']//prints 225
 println response.data //Always null?!
response.data始终为null,即使我使用Google Chrome的postman客户端尝试相同的请求时,我也会返回预期的响应主体.这是RESTClient的已知问题吗?
我在使用Java Config升级到Spring Security 3.2时遇到一些困难,需要自定义RoleVoter删除ROLE_前缀.具体来说,我从原始XML中得到了这个:
<!-- Decision Manager and Role Voter -->
<bean id="accessDecisionManager"
    class="org.springframework.security.access.vote.AffirmativeBased">
    <property name="allowIfAllAbstainDecisions">
        <value>false</value>
    </property>
    <property name="decisionVoters">
        <list>
            <ref local="roleVoter" />
        </list>
    </property>
</bean>
<bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter">
    <property name="rolePrefix">
        <value />
    </property>
</bean>
我试图在我的@Configuration对象中创建类似的配置
@Bean
public RoleVoter roleVoter() {
    RoleVoter roleVoter = new RoleVoter();
    roleVoter.setRolePrefix("");
    return roleVoter;
}
@Bean
public AffirmativeBased accessDecisionManager() {
    AffirmativeBased affirmativeBased = new AffirmativeBased(Arrays.asList((AccessDecisionVoter)roleVoter()));
    affirmativeBased.setAllowIfAllAbstainDecisions(false);
    return affirmativeBased;
}
...
@Override
protected void configure(HttpSecurity http) throws Exception
{ …java ×2
spring ×2
eclipselink ×1
findbugs ×1
gradle ×1
groovy ×1
httpbuilder ×1
jpa ×1
maven ×1
pom.xml ×1
sonarqube ×1
spring-boot ×1
vagrant ×1