小编lou*_*ros的帖子

使用自定义基本URL为Keycloak docker配置反向代理

如何设置docker keycloak base urlas参数?

我有以下nginx反向代理配置:

server {
    listen 80;
    server_name example.com;

    location /keycloak {
        proxy_pass http://example.com:8087/;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试访问http://example.com/keycloak/时,我获得了一个keycloak http重定向到http://example.com/auth/而不是http://example.com/keycloak/auth/

有任何想法吗?

nginx docker keycloak

21
推荐指数
4
解决办法
1万
查看次数

使用spring-boot-starter-test和cassandra进行单元测试

我的spring boot Web应用程序通过Datastax客户端使用Cassandra DB,连接如下:

public CassandraManager(@Autowired CassandraConfig cassandraConfig) {
  config = cassandraConfig;
  cluster = Cluster.builder()
      .addContactPoint(config.getHost())
      .build();
  session = cluster.connect(config.getKeyspace());
}
Run Code Online (Sandbox Code Playgroud)

当我运行单元测试时,spring boot应用程序尝试加载CassandraManager Bean并连接到Cassandra DB,而不是单元测试,因为我不需要它.我收到以下错误:[localhost/127.0.0.1:9042] Cannot connect)

有没有办法避免加载这个Cassandra Manager Bean来运行我的UT,因为他们不需要连接到数据库?这样做是一种好习惯吗?

unit-testing cassandra datastax spring-boot-test

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

Angular2 routerLink片段与变量

是否可以做类似的事情:

<ul>
    <li *ngFor="let language of languages">
        <a [routerLink]="['#' + language]">{{language}}</a>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

要么

<ul>
    <li *ngFor="let language of languages">
        <a fragment="language">{{language}}</a>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

保持不变url并添加#en#es还是#fr取决于language值是多少?我不能使它工作。

angular2-routing angular

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

在Protractor中的httpBackend API模拟模块中打印请求

我在量角器中使用角度服务$ httpBackend对模拟的API运行我的e2e测试.

我已经有了selenium浏览器的调试日志:

afterEach(function() {
  browser.manage().logs().get('browser').then(function(browserLog){
    if(browserLog.length) {
      for (var i = 0; i < browserLog.length; i++) {
        if( typeof browserLog[i] !== 'undefined') {
          console.log(
            JSON
            .parse(browserLog[i].message).message.parameters[0].value
          );
        }
      };
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

我想在我的httpBackend模块中打印每个请求的URL标题(例如,对于用户资源):

$httpBackend
  .whenGET(/^\/api\/users.*$/)
  .respond(function(method, url, data, headers) {
     var users = mockUserService.getData();
     console.log(url);
     console.log(headers);
     return [200, users, {}];
});
Run Code Online (Sandbox Code Playgroud)

但是在httpBackend模块内的任何地方都没有记录任何内容.当我在我的应用程序中使用它时它工作正常,但是当我在量角器中使用它时它没有.

有没有办法在任何地方打印?即使在输出文本文件中?

angularjs protractor httpbackend ngmocke2e e2e-testing

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

Jackson + Autovalue Builder bean验证

我有以下EventDTO课程:

@AutoValue
@JsonDeserialize(builder = AutoValue_Event.Builder.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class Event {

    public static Event.Builder builder() {
        return new AutoValue_Event.Builder();
    }

    public abstract UUID id();

    @NotNull
    public abstract Type type();

    @NotNull
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    public abstract LocalDate date();

    @AutoValue.Builder
    public abstract static class Builder {

        @JsonProperty("id")
        public abstract Builder id(UUID id);

        @JsonProperty("type")
        public abstract Builder type(Type type);

        @JsonProperty("date")
        public abstract Builder date(LocalDate date);

   }
}
Run Code Online (Sandbox Code Playgroud)

验证适用于typedate属性,并且JsonMappingException当有效负载不正确时,杰克逊会按预期抛出.不幸的是,返回的错误消息text/plain如下: …

spring jackson java-8 auto-value

7
推荐指数
0
解决办法
667
查看次数

FormArray验证中的Angular2 FormGroup

我有以下型号:

export interface Content {
  lang: string;
  title: string;
}
Run Code Online (Sandbox Code Playgroud)

我需要验证contents FormArray这个parent FormGroup:

this.formBuilder.group({
  defaultLang: ['', Validators.required],
  contents: this.formBuilder.array([], Validators.minLength(1))
});
Run Code Online (Sandbox Code Playgroud)

对于Content我的每个人,我contents FormArray使用以下内容验证模型content FormGroup:

this.formBuilder.group({
  lang: ['', Validators.required],
  title: ['', Validators.required]
});
Run Code Online (Sandbox Code Playgroud)

现在,我想补充以下content FormGroupcontents FormArray来验证每个Content:

(<FormArray>parentFormGroup.controls['contents'])
    .push(this.contentFormGroup);
Run Code Online (Sandbox Code Playgroud)

但是使用这种方法我无法验证这些规则:

  • 如果Content填写了其中一个字段,则会进行内容验证(这意味着要添加content FormGroup到内容中contents FormArray)
  • 如果没有填写任何内容字段,则不会发生内容验证(这意味着删除content FormGroupcontents FormArrayif if)
  • 如果langContentdefaultLangparent FormGroup …

validation angular2-forms angular

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

lambda vs匿名类

我有以下代码:

eventBus.subscribe(new EventBusListener<NavigationEvent>() {
    @Override
    public void onEvent(Event<NavigationEvent> event) {
        event.getPayload();
    }
});

eventBus.subscribe(new EventBusListener<NotificationEvent>() {
    @Override
    public void onEvent(Event<NotificationEvent> event) {
        event.getPayload();
    }
});
Run Code Online (Sandbox Code Playgroud)

IntelliJ告诉我,我可以用lambda表达式替换这两个匿名类,如:

eventBus.subscribe((EventBusListener<NavigationEvent>) Event::getPayload);
eventBus.subscribe((EventBusListener<NotificationEvent>) Event::getPayload);
Run Code Online (Sandbox Code Playgroud)

编译效果很好,但在运行时,出现以下错误的应用程序崩溃:java.lang.IllegalArgumentException: Could not resolve payload type引起getPayload()Event<T>类.

我是缺少什么lamdbasgenerics

generics lambda anonymous-class java-8

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

Spring @ExceptionHandler和多线程

我有以下控制器建议:

@ControllerAdvice
public class ExceptionHandlerAdvice {

    @ExceptionHandler(NotCachedException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public ModelAndView handleNotCachedException(NotCachedException ex) {
        LOGGER.warn("NotCachedException: ", ex);
        return generateModelViewError(ex.getMessage());
    }

}
Run Code Online (Sandbox Code Playgroud)

它在大多数情况下工作得很好但是当从使用@Async注释的方法抛出NotCachedException时,异常处理不正确.

@RequestMapping(path = "", method = RequestMethod.PUT)
@Async
public ResponseEntity<String> store(@Valid @RequestBody FeedbackRequest request, String clientSource) {
    cachingService.storeFeedback(request, ClientSource.from(clientSource));
    return new ResponseEntity<>(OK);
}
Run Code Online (Sandbox Code Playgroud)

这是Executor的配置:

@SpringBootApplication
@EnableAsync
public class Application {

private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        SettingsConfig settings = context.getBean(SettingsConfig.class);
        LOGGER.info("{} ({}) started", settings.getArtifact(), settings.getVersion());
        createCachingIndex(cachingService);
    }

    @Bean(name …
Run Code Online (Sandbox Code Playgroud)

java spring multithreading

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

如何在服务器端使用Apache服务器呈现Angular应用程序?

我们构建了一个由Apache服务器提供服务的Angular v> 4应用程序.我知道它存在Angular Universal for Node服务器以允许服务器端呈现.是否存在Apache Server的任何等效项?

谢谢.

apache server-side angular

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

如何在 MUI Popover 中使用 Link react-router?

我定义index.jsRouter来自 react router 5 的入口点(不是你不应该在 <Router> 之外使用 <Link>的副本):

ReactDOM.render(
    <Provider store={store}>
        <Router history={history}>
            <App />
        </Router>
    </Provider>,
    document.getElementById('app'),
);
Run Code Online (Sandbox Code Playgroud)

但我仍然有著名的You should not use <Link>outside a<Router> error on my component using Material UI Popover

const InterventionMarker = ({ marker, history }) => {

  const [anchorEl, setAnchorEl] = React.useState(null);
  const handleClick = event => setAnchorEl(event.currentTarget);
  const handleClose = () => setAnchorEl(null);
  const open = Boolean(anchorEl);

  return (
    <MarkerWithLabel
      onClick={handleClick}
      ...other-props
    >
      <div> …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router react-router-dom

6
推荐指数
0
解决办法
447
查看次数