小编khm*_*ise的帖子

Bash完成

我试图在我的bash(3.2.25)中加载bash_completion,它不起作用.没有消息等我在.bashrc中使用了以下内容

if [ -f ~/.bash_completion ]; then
  . ~/.bash_completion
fi
Run Code Online (Sandbox Code Playgroud)

我也尝试使用.bash_profile,但结果相同.所以问题是它为什么不起作用?任何的想法?提示?

bash tab-completion

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

升级Jersey版本后,随机REST API调用失败

最近不得不将Jersey的版本从2.5.1(稍后解释)升级到2.7并且自升级以来,每次我将代码上传到服务器时,随机API调用开始失败,使用以下堆栈跟踪:

org.glassfish.jersey.internal.Errors logErrors: The following warnings have been detected: WARNING: HK2 service reification failed for [com.example.rest.LeaderboardApi] with an exception:
MultiException stack 1 of 2
java.lang.NullPointerException
        at org.jvnet.hk2.internal.Utilities.hasInjectAnnotation(Utilities.java:1484)
        at org.jvnet.hk2.internal.Utilities.findInitializerMethods(Utilities.java:1425)
        at org.jvnet.hk2.internal.DefaultClassAnalyzer.getInitializerMethods(DefaultClassAnalyzer.java:102)
        at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getInitializerMethods(JerseyClassAnalyzer.java:239)
        at org.jvnet.hk2.internal.Utilities.getInitMethods(Utilities.java:243)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:163)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:200)
        at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:649)
        at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:604)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:405)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2046)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.access$700(ServiceLocatorImpl.java:116)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1011)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1006)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
        at java.util.concurrent.FutureTask.run(FutureTask.java:260)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:292)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetDescriptor(ServiceLocatorImpl.java:1093)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:616)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
        at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
        at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
        at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at …
Run Code Online (Sandbox Code Playgroud)

java google-app-engine jersey-2.0

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

Maven 配置文件中“properties-maven-plugin”和“filter”的目的是什么

我想对 maven 过滤器标签以及它如何对应于插件 properties-maven-plugin 中的文件标签进行解释。

有问题的个人资料:

<profile>
    <id>local-spm-caefeeder-preview</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-1</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                        <quiet>true</quiet>
                        <files>
                            <file>${main.basedir}/src/config/global.properties</file>
                            <file>${main.basedir}/src/config/caefeeder/caefeeder_global.properties</file>
                            <file>${main.basedir}/src/config/caefeeder/caefeeder_preview.properties</file>
                            <file>${main.basedir}/src/config/local.properties</file>
                            <file>${main.basedir}/src/config/${user.name}.properties</file>
                        </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <filters>
            <filter>${main.basedir}/src/config/caefeeder/caefeeder_global.properties</filter>
            <filter>${main.basedir}/src/config/caefeeder/caefeeder_preview.properties</filter>
            <filter>${main.basedir}/src/config/local.properties</filter>
            <filter>${main.basedir}/src/config/${user.name}.properties</filter>
        </filters>
    </build>
</profile>
Run Code Online (Sandbox Code Playgroud)

根据我的研究过滤器定义了其中包含需要替换的变量的文件。“properties-maven-plugin”是否从文件标签中定义的文件中提供这些变量?

configuration maven

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

在测试和prod环境中使用Maven和Jenkins部署到tomcat

我正在为我的应用程序编写构建脚本,并且想知道在test/prod环境中部署/发布的最佳实践是什么.

目前我所写的是

  1. 使用ssh停止tomcat服务器.
  2. 使用Maven建立战争
  3. 使用ssh从tomcat webapps目录中删除战争
  4. 使用ssh将构建的文件传输到tomcat上的webapps目录
  5. 启动服务器

我知道它不是部署应用程序的最佳方式,并希望得到您的反馈.我理想的做法是

  1. 为prod env执行maven发布.如果可能,最多为修订号.
  2. 标记代码.
  3. 将已发布的战争上传到包含所有战争及其历史记录的S3文件夹.
  4. 在将从S3下载文件的服务器/ Jenkins上编写脚本(版本号,如果提供最新的版本)并部署到tomcat.

我很困惑这个步骤4应该是在Jenkins还是在服务器上.我正在使用EC2实例来托管Web应用程序,因此我的图像需要有脚本.

java deployment tomcat maven jenkins

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

Git 不会删除忽略目录中的 git 存储库

我有一个.gitignore包含该target目录的文件。现在我意识到 git git 不会删除目录中的 git 存储库,target即使我这样做:

$ git clean -fdx
Skipping repository target/x
Run Code Online (Sandbox Code Playgroud)

有没有解决方案来处理这个问题?特殊配置选项?因为我已经给予了-f力量等?

更新:

我可以target通过以下手动步骤在目录中手动创建存储库:

maven-it-extension (issue-21)$ git st
On branch issue-21
Your branch is up to date with 'origin/issue-21'.

nothing to commit, working tree clean
maven-it-extension (issue-21)$ mkdir target/x
mkdir: target: No such file or directory
maven-it-extension (issue-21)$ mkdir -p target/x
maven-it-extension (issue-21)$ cd target/x/
x (issue-21)$ git init .
Initialized empty Git repository in /Users/khmarbaise/ws-git-apache/maven-it-extension/target/x/.git/
x (master …
Run Code Online (Sandbox Code Playgroud)

git gitignore

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

通过cypress.get()选择HTML中的元素

我正在使用cypress为html网站编写一些测试..

以下tr内容从我的HTML网站上的表中正确选择了一个元素.网站内容如下所示:

<tr data-recordid="theId">
  <td...><div ..>Text 1</div></td>
  <td...><div ..>Text 2</div></td>
  <td...><div ..>Text 3</div></td>
</tr>
Run Code Online (Sandbox Code Playgroud)

以下测试脚本片段正确选择了我的单个<tr..>部分.

cy.get('tr[data-recordid="theId"]').contains('Text')
Run Code Online (Sandbox Code Playgroud)

现在我想选择<div>..</div> 标签中的文本.我首先试图为第一个<div>..</div>标签链接一个调用,如下所示:

cy.get('tr[data-recordid="theId"]').get('div').contains('Text')
Run Code Online (Sandbox Code Playgroud)

这不符合我的预期.该get()呼叫链jQuery的调用(基于Cypress的文档).所以看起来我误解了JQuery中的工作原理.

我期待的是如何检查所有div元素(不工作):

cy.get('tr[data-recordid="theId"]')..SomeHowMagic
  .get('td[alt="xyz"]".get('div').contains('Text 1')
  .get('td...').get('div').contains('Text 2')
  .get('td...').get('div').contains('Text 3')
Run Code Online (Sandbox Code Playgroud)

知道如何迈出一步吗?遗漏任何信息只是发表评论.

html javascript jquery cypress

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

使用@WebMvcTest 测试中的 ApplicationContext 异常

我有一个 Spring Boot 应用程序 (1.5.10.RELEASE),其中包含一个主要的 (SpringBootApplication),如下所示:

@SpringBootApplication
@Configuration
@EntityScan(basePackages = { "db.modell", "db.modell.base" })
@ComponentScan(basePackages = { "de.gui.test" })
public class SpringBootConsoleApplication {
   public static void main(String[] args) throws Exception {
    SpringApplication.run(SpringBootConsoleApplication.class, args);
  }
}
Run Code Online (Sandbox Code Playgroud)

和两个 REST 控制器,如下所示:

@RestController
@RequestMapping("/as")
public class AController {
  @Autowired
  private ARepository aRepository;

  @RequestMapping(method = RequestMethod.GET)
  public ResponseEntity<Collection<A>> getAs() {
    return new ResponseEntity<>(orgtFarbeRepository.findAll(), HttpStatus.OK);
  }

  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public ResponseEntity<A> getA(@PathVariable long id) {
    A a = ARepository.findOne(id);

    if (party != null) …
Run Code Online (Sandbox Code Playgroud)

rest unit-testing spring-boot-test

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

“ mat-form-field”不是已知元素

目前,我有一个包含以下内容的角度组件 x.component.html(使用角度材料):

<div class="example-container mat-elevation-z8">

  <div class="example-header">
    <mat-form-field>
      <input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
    </mat-form-field>
  </div>

  <mat-table #table [dataSource]="dataSource">
    <ng-container matColumnDef="farbeKey">
      <mat-header-cell *matHeaderCellDef> farbeKey </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.farbeKey}} </mat-cell>
    </ng-container>
    ....
Run Code Online (Sandbox Code Playgroud)

此外,我有x.component.ts看起来像这样的组件:

<div class="example-container mat-elevation-z8">

  <div class="example-header">
    <mat-form-field>
      <input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
    </mat-form-field>
  </div>

  <mat-table #table [dataSource]="dataSource">
    <ng-container matColumnDef="farbeKey">
      <mat-header-cell *matHeaderCellDef> farbeKey </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.farbeKey}} </mat-cell>
    </ng-container>
    ....
Run Code Online (Sandbox Code Playgroud)

但是问题是,如果尝试在浏览器中访问它,则会收到以下错误消息(这仅是摘录):

Uncaught Error: Bootstrap's JavaScript requires jQuery
    at scripts.bundle.js:8
(anonymous) @ scripts.bundle.js:8
compiler.js:485 Uncaught Error: …
Run Code Online (Sandbox Code Playgroud)

javascript angular-material2 angular

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

Java 16:替换几个字母

我有一个有点不寻常的问题。我目前正在尝试在 Java 16 中编写一个用于处理不和谐的聊天过滤器。

\n

在这里我遇到了一个问题,在德语中,有几种方法可以编写一个单词来绕过这个过滤器。

\n

作为一个例子,我现在以侮辱“Hurensohn”为例。\n现在你可以简单地在聊天中写“Hur \xc3\xa4 nsohn”或“Hur 3 nsohn”,从而很容易地绕过过滤器。

\n

由于我不想手动将所有可能性打包到过滤器中,所以我考虑了如何自动完成它。所以我做的第一件事是创建一个包含所有可能的替代字母的哈希图,它看起来像这样:

\n
Map<String, List<String>> alternativeCharacters = new HashMap<>();\nalternativeCharacters.put( "E", List.of( "\xc3\xa4", "3" ) );\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试更改单词中对应的字母并将其添加到聊天过滤器中,这确实有效。

\n

但现在我们遇到了问题:\n为了能够覆盖所有可能的组合,仅更改单词中的一种类型的字母对我来说并没有多大好处。

\n

如果我们现在取单词“Einschalter”并更改此处的字母“e”,我们也可以简单地将此处的“e”更改为“3”或“\xc3\xa4”,从而会出现以下结果:

\n
    \n
  • 3einschal3r
  • \n
  • 艾因沙尔特3r
  • \n
  • 3英寸沙尔特
  • \n
\n

\n
    \n
  • \xc3\x84inschal\xc3\xa4r
  • \n
  • 艾因沙尔特\xc3\xa4r
  • \n
  • \xc3\x84安装
  • \n
\n

但现在我也想创造“混合”词。例如“3inschal\xc3\xa4r”,其中“\xc3\x84”和“3”都用于创建单词。然后会出现以下组合:

\n
    \n
  • 3inschal\xc3\xa4r
  • \n
  • \xc3\x84inschalt3r
  • \n
\n

有谁知道我怎样才能实现这样的事情?使用普通的 Replace() 方法,我还没有找到创建“混合”替换的方法。

\n

我希望人们理解我有什么样的问题以及我想做什么。:D

\n

目前用于替换的方法:

\n
    public static List<String> replace( String word, String from, String... to ) {\n\n …
Run Code Online (Sandbox Code Playgroud)

java string replace java-16

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