小编Mic*_*fel的帖子

如何阻止Nexus中的特定Maven工件

我们通过本地Nexus存储库使用Maven。不幸的是,在查询新版本时,我们得到了一些误报:

commons-collections:commons-collections ............ 3.2.1 -> 20040616
org.hibernate:hibernate-entitymanager ..... 4.1.9.Final -> 4.3.0.Beta1
Run Code Online (Sandbox Code Playgroud)

第一个是古老的版本,但命名方案不正确。第二个实际上只是一个beta版本(我们通常不会得到这些版本,但是有些似乎会漏掉)。现在的问题是:如何排除这些不是我们存储库中真正存在的版本,而是来自Nexus所指的存储库之一的版本?

我尝试过路由,但是要么我弄错了它,要么它不能阻止特定版本,只能阻止所有版本的完整工件。我在文档中看到了采购,但是看起来很复杂,我也不敢尝试。

nexus maven

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

使用 spring-boot-starter-oauth2-client 检索 OAuth2 3-legged 身份验证的访问令牌

我想知道如何使用提供的功能在 Spring Boot 3-legged 身份验证上检索访问令牌 org.springframework.boot:spring-boot-starter-oauth2-client

我能够使用常规RestTemplate调用获取访问令牌。

我尝试spring-boot-starter-oauth2-client按照https://github.com/wonwoo/spring-boot-oauth2-login 中的示例使用这些功能获取相同的访问令牌。

我能够检索服务器提供的代码,但我不知道如何获取访问令牌。

我的代码如下所示:

属性在application.properties

spring.security.oauth2.client.registration.my-client-name-here.client-id=__client_id_here__
spring.security.oauth2.client.registration.my-client-name-here.client-secret=__client_secret_here__
spring.security.oauth2.client.registration.my-client-name-here.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.my-client-name-here.redirect-uri-template=http://localhost:8080/authentication/3leggedtoken/callback
spring.security.oauth2.client.registration.my-client-name-here.scope=data:read
spring.security.oauth2.client.registration.my-client-name-here.client-name=__client_name_here__
spring.security.oauth2.client.registration.my-client-name-here.client-authentication-method=POST
spring.security.oauth2.client.provider.my-client-name-here.token-uri=https://example.com/api/token
spring.security.oauth2.client.provider.my-client-name-here.authorization-uri=https://example.com/api/authorize
spring.security.oauth2.client.provider.my-client-name-here.user-info-uri=
spring.security.oauth2.client.provider.my-client-name-here.user-name-attribute=
Run Code Online (Sandbox Code Playgroud)

Thymeleaf 模板在login.html

spring.security.oauth2.client.registration.my-client-name-here.client-id=__client_id_here__
spring.security.oauth2.client.registration.my-client-name-here.client-secret=__client_secret_here__
spring.security.oauth2.client.registration.my-client-name-here.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.my-client-name-here.redirect-uri-template=http://localhost:8080/authentication/3leggedtoken/callback
spring.security.oauth2.client.registration.my-client-name-here.scope=data:read
spring.security.oauth2.client.registration.my-client-name-here.client-name=__client_name_here__
spring.security.oauth2.client.registration.my-client-name-here.client-authentication-method=POST
spring.security.oauth2.client.provider.my-client-name-here.token-uri=https://example.com/api/token
spring.security.oauth2.client.provider.my-client-name-here.authorization-uri=https://example.com/api/authorize
spring.security.oauth2.client.provider.my-client-name-here.user-info-uri=
spring.security.oauth2.client.provider.my-client-name-here.user-name-attribute=
Run Code Online (Sandbox Code Playgroud)

配置SecurityConfig.java

<div th:each="registration: ${registrations}">
  <a th:href="@{${registration.uri}}">
      Sign in with [[${registration.clientName}]]
  </a>
</div>
Run Code Online (Sandbox Code Playgroud)

控制器AuthenticationController.java

@Configuration
@EnableWebSecurity
public class SegurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http_security) throws Exception {
        http_security.authorizeRequests().requestMatchers(PathRequest.toStaticResources().atCommonLocations()) …
Run Code Online (Sandbox Code Playgroud)

spring-security access-token oauth-2.0 spring-boot

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

在DB中检索超过5分钟的元素

我正在使用播放框架版本1.2.5,我想检索所有未更新其会话5分钟的连接用户,然后我想将其连接状态设置为"已断开连接".

这是我的模型:

@Entity
public class User extends Model {

    @Required
    public String name;

    public boolean isConnected;

    public Date lastConnectionDate;

}
Run Code Online (Sandbox Code Playgroud)

以下是更新用户的Job:

Date fiveMinsAgo = new Date(new Date().getTime() - 5 * 60);
List<User> list = User.find("select u from User u where u.isConnected = true and u.lastConnectionDate < ?", fiveMinsAgo).fetch();

for (User user : list) {
    // We set these accounts as disconnected
    user.isConnected = false;
    user.save();
}
Run Code Online (Sandbox Code Playgroud)

这段代码似乎不起作用.即使用户的lastConnectionDate不早于5分钟,用户也会设置为"已断开连接" .我做错什么了吗 ?

有没有更好的方法/代码来做我想做的事情?(比如UPDATE命令)

谢谢您的帮助

java

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

在 lombok 之后未调用覆盖 Setter 方法

我用 Lombok 进行注释。我需要覆盖其中一个属性的 setter 方法。但这是行不通的。

我已经注释了属性,@Setter(AccessLevel.NONE)然后显式调用setProperty

下面提到豆子。

@Data
@AllArgsConstructor
@Slf4j
public class TestDto
{

    private String code;

    @Setter(AccessLevel.NONE)
    private String nameCode;

    public void setNameCode(String nameCode)
    {
        log.info("  nameCode   {}", nameCode);
        this.nameCode = <Call to some method>;
    }

}
Run Code Online (Sandbox Code Playgroud)

在其中设置 bean 列表的 DTO。

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TestViewDto {
    private List<TestDto> testDtoList;
    .............Few more dto's..............................
    }
Run Code Online (Sandbox Code Playgroud)

这是从服务线下调用的..

travelAgentViewDto.setTestDto(repository.findTestNumber(number);
Run Code Online (Sandbox Code Playgroud)

存储库接口定义如下:

public interface Repository extends JpaRepository<Address, AddressPk> {
        public List<TestDto> findTestNumber(String number);

}
Run Code Online (Sandbox Code Playgroud)

代码工作正常。唯一的问题是当覆盖它时setNameCode不会进入 setter。

从 …

java setter lombok spring-boot

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

番石榴入门

如何将Guava用于我的Web应用程序?我想用它来代替JUnit进行测试.那可能吗?如果我使用JSP和servlet构建webapps,我可以从Guava中获得什么其他用途?

java guava

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