小编Fab*_*mos的帖子

Spring OAuth 2:对资源的公共访问

如何在Spring Security OAuth-2 Rest应用程序中的特定URL中允许公共访问.

我的所有URL都以/rest/**安全方式启动,但希望/rest/about公开,因此我不需要用户进行身份验证即可访问它.我尝试过使用permitAll()但它仍然需要请求中的令牌.这是我的HttpSecurity配置:

@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends
        ResourceServerConfigurerAdapter {

    @Override
    public void configure(ResourceServerSecurityConfigurer resources) {
        resources.resourceId(RESOURCE_ID);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/rest/about").permitAll()
                .antMatchers("/rest/**").authenticated()
                ;
    }
}
Run Code Online (Sandbox Code Playgroud)

GET请求/rest/about仍然返回401 Unauthorized - "error":"unauthorized","error_description":"Full authentication is required to access this resource"

rest spring spring-mvc spring-security oauth-2.0

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

如何禁用Postgresql消息转换

有没有办法禁用邮件的Postgresql翻译?我在pt_BR Windows机器上运行我的appl和Postgresql,当抛出异常时,错误消息被翻译成葡萄牙语,如:

引起:org.postgresql.util.PSQLException:ERRO:relação"unidade_federacao"nãoreistePosição:25

我希望这些消息以英文显示.

我在Java(带有Hibernate)应用程序上使用驱动程序postgresql-8.4-701.jdbc3.jar.

提前谢谢,FabrícioLemos

postgresql jdbc internationalization

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

Kotlin - 如何在 springBootTest 中管理 @BeforeClass 静态方法

我想在我的 springBootTest 中有一个 @BeforeClass 方法,它应该是静态的并在“伴随​​对象”中声明。

@RunWith(SpringRunner::class)
@SpringBootTest
@ActiveProfiles("test")
open class MyTest {
companion object {

    @Autowired
    lateinit var repo: MyRepository

    @BeforeClass
    @JvmStatic
    fun X() {
        user = User()
        repo.save(user)
    }

}
Run Code Online (Sandbox Code Playgroud)

另一方面,我应该在这个方法中使用一些 Autowired 组件,但正如这里提到的在静态上下文中是不可能的,我得到了这个错误:

lateinit property repo has not been initialized
Run Code Online (Sandbox Code Playgroud)

关于我应该如何处理这种情况的任何建议?

junit spring kotlin spring-boot spring-boot-test

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

不了解 Bundler 与 Gems 的交互

我以为我了解 Bundler 是如何处理 gem 的,但是在最近发生的事情之后,我不确定我的理解是否正确。

我正在开发一个 Rails 应用程序。首先(为了熟悉我以前从未使用过的 Rails 环境),我没有使用 IDE。但是,因为我错过了 IDE 的一些优势,所以我才开始使用 RubyMine。作为 RubyMine 设置的一部分,它要求更新我现有项目的所有 gem。

在那之后,我无法运行“rake [anything]”。每次我这样做时,我都会收到以下错误:

您已经激活了 rake 0.9.3.beta.1,但是您的 Gemfile 需要 rake 0.9.2.2。使用 bundle exec 可以解决这个问题。

我可以更新到下一个版本的 rake - 这不是问题 - 但我不明白首先发生了什么。我“激活”了较新版本的 rake 发生了什么。最终,我最终解决了这个问题

gem 'rake', '0.9.3.beta.1'
Run Code Online (Sandbox Code Playgroud)

在我的 Gemfile 中运行

bundle update rake
Run Code Online (Sandbox Code Playgroud)

但是,我仍然不确定这里发生了什么。如果我之前使用的是 9.2.2,为什么它会突然像那样爆炸,我将来如何防止这种情况发生?

rake gem ruby-on-rails rubymine bundler

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

在Spring-Boot中配置bean

PropertySourcesPlaceholderConfigurer在Spring-Boot应用程序中配置的正确方法是什么?

我有一个属性文件:

software.version=${project.version}
Run Code Online (Sandbox Code Playgroud)

我阅读了该属性,并且不希望Spring抱怨无法解析,${project.version}因为它稍后会被Maven取代.所以在我的@Configurarion我有:

@Configuration
@PropertySource("classpath:build.properties")
@ComponentScan
@EnableAutoConfiguration

public class Application {

    private String softwareVersion;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        configurer.setIgnoreUnresolvablePlaceholders(true);
        return configurer;
}

    @Value("${software.version}")
    public void setSoftwareVersion(String softwareVersion) {
        this.softwareVersion = softwareVersion;
    }
}
Run Code Online (Sandbox Code Playgroud)

但Spring-Boot似乎忽略了setIgnoreUnresolvablePlaceholders(true),我得到了例外:

[2014-08-20 13:54:31.888] boot - 3756 ERROR [main] --- SpringApplication: Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Injection of autowired dependencies failed; …
Run Code Online (Sandbox Code Playgroud)

java spring maven spring-boot

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

键盘无法滚动上方的 EditText

我正在使用这段代码。但是,当我单击 EditText 打开键盘时,视图并未完全打开。为什么视图没有一路上升,EditText隐藏在键盘后面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:background="@drawable/main_bg" 
    android:id="@+id/mainLayout"
    android:focusableInTouchMode="true"
    >

       <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:orientation="horizontal"
        android:id="@+id/topBar"
        android:background="@drawable/top_bar_bg"
     >

        <LinearLayout 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_horizontal|bottom"
                android:layout_centerInParent="true"
            >

                 <ImageView 
                     android:id="@+id/loadingAnimationImg"
                     android:layout_height="35dp"
                     android:layout_width="35dp"
                     android:adjustViewBounds="true"
                     android:contentDescription="@null"
                     android:background="@drawable/img05"/>

                 <ImageView 
                     android:layout_marginBottom="5dp"
                     android:layout_height="wrap_content"
                     android:layout_width="120dp"
                     android:adjustViewBounds="true"
                     android:contentDescription="@null"
                     android:src="@drawable/simple_logo"/>

         </LinearLayout>
    </RelativeLayout>

    <GridView
            android:layout_marginTop="5dp"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:id="@+id/gridView"
            android:numColumns="5"
            android:verticalSpacing="5dp" />

    <TextView 
        android:layout_marginTop="5dp"
        android:layout_marginLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        android:textColor="@android:color/white"
        android:text="@string/hashtagText"
        />


    <com.trib.devicebee.custom.FlowLayout 
        android:id="@+id/flowLayout"
        android:layout_margin="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <EditText 
        android:layout_margin="10dp"
        android:id="@+id/hashTagsText"
        android:hint=""
        android:inputType="textFilter" 
        android:singleLine="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        />

    <Button …
Run Code Online (Sandbox Code Playgroud)

java android

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