小编Syd*_*ney的帖子

默认SSL上下文init失败:null

创建SSL服务器时,我遇到了以下异常:Default SSL context init failed: null.它似乎来自它无法找到密钥库和信任库的事实.我尝试从jar文件中设置它们.该文件存在于jar中,但似乎无法找到该资源.

String keystore = TestFramework.class.getResource("/security/keystore.jks").getFile();
System.setProperty("javax.net.ssl.keyStore", keystore);
System.setProperty("javax.net.ssl.keyStorePassword", password);
String truststore = TestFramework.class.getResource("/security/truststore").getFile();
System.setProperty("javax.net.ssl.trustStore", truststore);
System.setProperty("javax.net.ssl.trustStorePassword", "ebxmlrr");
Run Code Online (Sandbox Code Playgroud)

我运行了一个ls命令来检查文件是否存在.它存在.然后我通过运行命令来检查keystore.jks是否存在jar -tf myjar.jar | grep security并且它存在.

security/
security/keystore.jks
security/truststore
Run Code Online (Sandbox Code Playgroud)

我的应用程序在Tomcat下运行.

java ssl

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

将下拉式角带与ng网格集成

我想将单元格模板化为下拉按钮.所以我创建了一个单元格模板,其中的按钮链接到下拉指令.如果我在网格外创建这个按钮,它正在工作,但在网格内部则不然.我不确定,但我想$scope模板中无法访问.

我创建了一个显示问题的Plunker

angularjs angular-ui ng-grid

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

注入bower依赖与gulp - 相对路径问题

我想用gulp-inject和注入bower依赖项main-bower-files.拾取依赖关系,但生成的路径是绝对的.

我得到了/www/lib/angular/angular.js,但我想要lib/angular/angular.js

<!-- bower:js -->
<script src="/www/lib/angular/angular.js"></script>
<!-- endinject -->
Run Code Online (Sandbox Code Playgroud)

.bowerrc

{
  "directory": "www/lib"
}
Run Code Online (Sandbox Code Playgroud)

gulpfile.js

var gulp = require('gulp');
var inject = require('gulp-inject');
var mainBowerFiles = require('main-bower-files');
var debug = require('gulp-debug');

gulp.task('index', function () {
    return gulp.src('./www/index.html')
        .pipe(inject(gulp.src(mainBowerFiles(), {read: false}, {relative: true}), {name: 'bower'}))
        .pipe(gulp.dest('./www'));
});
Run Code Online (Sandbox Code Playgroud)

gulp gulp-inject

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

AngularJS指令将参数传递给隔离范围函数

我写了一个指令,为每个传递给指令的产品显示一个按钮.subscribe单击按钮时,也应将产品传递给指令的功能.

我遇到的问题是该参数未传递给该函数.

指令

directives.directive('subscriptionItem', function () {
    return {
        scope: {
            // Two way binding, = is equivalent to '=activeSubscription'
            activeSubscription: '=',
            products: '=',
            googleLogin: '&',
            subscribe: '&'
        },
        restrict: 'E',
        replace: 'true',
        templateUrl: 'common/directives/subscription-item.tpl.html'
    };
});
Run Code Online (Sandbox Code Playgroud)

模板

<div>
    <ion-item class="item-text-wrap">
        <h2>{{activeSubscription.status}} - {{activeSubscription.action}}</h2>

        <p>{{activeSubscription.description}}</p>
    </ion-item>
    <ion-item ng-repeat="product in products" class="item-text-wrap" ng-if="activeSubscription.action === 'PAID'">
        <h2>{{product.title | limitTo: product.title.length - 21}}</h2>

        <p>{{product.description}}</p>
        <button class="button button-block button-positive" ng-click="subscribe(product.productId)">
            Buy for {{product.price}} - {{product.productId}}
        </button>
    </ion-item>
</div>
Run Code Online (Sandbox Code Playgroud)

product.productId显示正常,但不能传递给函数.

指令用法 …

angularjs angularjs-directive

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

Angular:全局错误处理程序仅工作一次

我有一个调用REST API的服务。的create操作POST的参数,并且然后通过使用GET创建的对象id在HTTP头中返回。返回对象时,主题会传播该对象以通知其他组件。您可能会注意到,我没有给您打电话catch。我是故意这样做的,因此全局错误处理程序可以管理错误。它第一次按预期工作,但是第二次不调用全局错误处理程序。

在Chrome控制台中,在第一次致电后出现错误,但在第二次致电后没有发生错误rxjs/Subscriber.js

Subscriber.js:240 Uncaught 
Response {_body: "{"message":"The query is not valid"}", status: 500, ok: false, statusText: "Internal Server Error", headers: Headers…}

SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            this.unsubscribe();
            throw err;
        }
    };
Run Code Online (Sandbox Code Playgroud)

服务:

@Injectable()
export class SystemService {

  private subject = new Subject<any>();

  constructor(private http: Http) {
  }

  create(system: SdqlSystem) {
    this.http.post(environment.apiEndpoint + 'systems', system)
      .flatMap(res => {
        const location = res.headers.get('Location');
        return …
Run Code Online (Sandbox Code Playgroud)

angular

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

如何设置liquibase类路径

我创建了一个JHipster项目。我想手动运行liquibase变更集。默认情况下,变更集包含在类路径中。更新日志在src/main/resources/config/liquibase/master.xml,变更集在src/main/resources/config/liquibase/changelog

<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">

    <include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
    <!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
    <!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>
Run Code Online (Sandbox Code Playgroud)

运行时mvn liquibase:update,出现错误,因为即使文件存在,变更集也不在类路径中:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project playground: Error setting up or running Liquibase: liquibase.exception.SetupException: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

因此,我尝试通过设置类路径从命令行运行。

liquibase --classpath=src/main/resources --classpath=postgresql-42.1.3.jar 
--url=jdbc:postgresql://localhost:5432/playground 
--driver=org.postgresql.Driver 
--changeLogFile=src/main/resources/config/liquibase/master.xml 
--username playground --password=***** update
Run Code Online (Sandbox Code Playgroud)

具有相同的错误: Unexpected error …

liquibase jhipster

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

CamelContextStartedEvent 被调用两次

CamelContextStartedEvent对于相同的骆驼上下文 (camel-1) 被调用两次。问题可能是我注册的方式EventNotifier。您可以使用 Spring Boot 1.5.14、Spring Boot Camel Starter 2.21.1 和 Spring Boot Web Starter 来重现该问题。

查看日志:

2018-07-06 11:04:41.104  INFO 19092 --- [           main] o.a.camel.spring.SpringCamelContext      : Apache Camel 2.21.1 (CamelContext: camel-1) is starting
2018-07-06 11:04:41.106  INFO 19092 --- [           main] o.a.c.m.ManagedManagementStrategy        : JMX is enabled
2018-07-06 11:04:41.191  INFO 19092 --- [           main] o.a.camel.spring.SpringCamelContext      : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2018-07-06 11:04:41.193  INFO …
Run Code Online (Sandbox Code Playgroud)

spring apache-camel spring-boot spring-camel

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

@WebMvcTest 由于缺少依赖项而未运行

我想使用 来测试我的控制器@WebMvcTest。我有@MockBean控制器的依赖项,但在运行测试时,它无法启动。运行主类时应用程序正确启动。

考试:

@RunWith(SpringRunner.class)
@WebMvcTest(MetricResource.class)
public class MetricResourceTest {

    @Autowired
    private MockMvc mvc;

    @MockBean
    private MetricService metricService;

    @MockBean
    private MetricMapper metricMapper;

    @Test
    public void test() {
    }

}
Run Code Online (Sandbox Code Playgroud)

控制器:

@RestController
@RequestMapping("/api/v1/metrics")
public class MetricResource {

    private final MetricService metricService;

    private final MetricMapper metricMapper;

    public MetricResource(MetricService metricService, MetricMapper metricMapper) {
        this.metricService = metricService;
        this.metricMapper = metricMapper;
    }

    @GetMapping
    public ResponseEntity<List<MetricDto>> getMetrics(@RequestParam(required = false) List<String> fields) {
        if (fields == null) {
            fields = new ArrayList<>();
        }
        List<Metric> …
Run Code Online (Sandbox Code Playgroud)

spring spring-boot

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

在https上使用安全的maven存储库

我阅读了文档,但我无法弄清楚是什么问题.

我配置我的POM来声明存储库:

<repositories>
    <repository>
        <id>snmp4j</id>
        <url>https://oosnmp.net/dist</url>
    </repository>
</repositories>

    <dependency>
        <groupId>org.snmp4j</groupId>
        <artifactId>snmp4j</artifactId>
        <version>2.2.2</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

然后我用Firefox导出证书.单击Lock - > More Information - > View Certificate - > Details - > Export ... - > snmp4j.crt

然后我将公钥导入我的信任库

keytool -importcert -file snmp4j.crt -keystore trust.jks -alias "snmp4j"
Run Code Online (Sandbox Code Playgroud)

我配置了maven选项

-Xmx512m -XX:MaxPermSize=128m -Djavax.net.ssl.trustStore=k:\home\ssl\trust.jks -Djavax.net.debug=ssl:handshake:data
Run Code Online (Sandbox Code Playgroud)

但是当我运行该mvn compile命令时,不会下载依赖项.至少我应该看到SSL调试跟踪.

ssl maven

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

git squash几个提交成一个

我想把最后12个提交压缩成一个.我尝试了这个命令,但得到一个致命的错误:

>git rebase -i HEAD~12
fatal: Needed a single revision
invalid upstream HEAD~12
Run Code Online (Sandbox Code Playgroud)

我有一个远程存储库,我已经推送了一些提交,但它并不重要,因为我将它推送到heroku,所以此代码不与其他用户共享.我之所以提到它,是因为我知道当一些提交已经提交时,重写历史记录并不好.

>git remote
heroku
Run Code Online (Sandbox Code Playgroud)

securityheroku分支已合并到master:

>git branch
  heroku-setup
* master
  security
Run Code Online (Sandbox Code Playgroud)

我的提交看起来像那样:

>git log --pretty=oneline
04d85b2959b73daff8ce0d49002c81469748798d Switch to Google OAUth 2.0
862cd0f7a9243d602dbeb1d670c08f20a1b832d8 Switch to Google OAUth 2.0
b25a48a657b9bf5087eaa9c1821163d0746b5ac2 Fix mongodb config
bd4c95dd25056a8a8bc6ed97faf01c7007d3f598 Setup Heroku
c82762c29fc1e5563082d710a1d241ce3ec7681f Setup Heroku
976d2baabe386eb1135e7789be167b081d40eeb0 Setup Heroku
e7ae7dd8755e75fc2bfd4bee460ad7f73b6e8ae4 Setup Heroku
6a389b55b782f37daa1c7434b68fe48100bb79e2 Setup Heroku
c26583bcf92f383c66526a29ee5642c3123b650e Setup Heroku
f7d36cf7215de13ade5ff537c3954f99f05506bd Setup Heroku
1110ed9efc60a27ac6334fb5987110de27983dcc Security with Passport
073d3ba79b727e2dc938aa4345f144baa66e05e3 Security with Passport
b82898acf97cc52f94a08e13388a7641460d8ef2 …
Run Code Online (Sandbox Code Playgroud)

git

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