小编ser*_*rah的帖子

Angular bindToController不工作,可以将对象从一个控制器作用域绑定到另一个控制器作用域

我使用的是Angular 1.5.7版本.

我有一个指令,它将控制器名称和视图名称作为字符串,然后分别调用控制器.

我无法将用户名绑定到上一个控制器的调用控制器,我看到我以前的控制器中可用的值.

请问您可以提出什么问题?

myApp.directive("pendingRequests", function() {
    return {
        restrict: 'E',
        controller: "@",
        name: "controllerName",
        controllerAs: 'pendingReqCtrl',
        scope: {},
        bindToController: {
            username: '=username'
        },
        templateUrl: function(tElement, tAttrs) {
            return tAttrs.templateUrl;
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

angularjs

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

在 Java 中测试 REST 服务的最佳方法

  1. 在 Java 中测试 REST 服务的最佳方法是什么?开发人员通常采用哪些方法和工具集?

  2. 此外,如果您正在编写调用第三方 REST 服务的 REST 客户端。测试 REST 客户端的最佳方法是什么。您是否有与第三方 REST 服务通信的 JUnit 测试。您可能会遇到服务不可用/或生产 REST 服务在没有某些凭据的情况下无法访问的风险。

java rest web-services

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

Swagger UI没有列出任何控制器/端点,尽管我能够在v2 / api-docs端点下看到json

我无法使Swagger UI与我的项目一起使用。Swagger UI很好用,但是它没有列出我的任何REST控制器。

我正在使用SPRING 4.2.6.RELEASE和Swagger 2.5.0。我的其余服务已部署到Tomcat 7.0.54。

当Tomcat 7.0.54出现时,它能够获取迅速的端点。我能够找到提取json消息的端点v2 / api-docs。我也可以点击swagger-ui,但没有列出任何控制器。下拉列表为空,如下所示

在此处输入图片说明

**我目前面临的问题是

  1. 我无法获取/ swagger-resources / configuration / ui,而当我启动swagger UI时却遇到404(未找到)错误,而该UI试图获取/ swagger-resources / configuration / ui。我为swagger-resources安装了资源处理程序,但这似乎无济于事。您能否让我知道可能会丢失什么?
  2. 我应该在扩展的WAR中看到META-INF下的resources文件夹吗?META-INF内应该有任何与springfox相关的文件/文件夹吗?**

Swagger的Maven依赖项
io.springfox springfox-swagger2 2.5.0
io.springfox springfox-swagger-ui 2.5.0

以下是我的SwaggerCongifuration

@EnableSwagger2
public class SwaggerConfiguration {

@Bean
public Docket api() {
    List<SecurityContext> security = new ArrayList<SecurityContext>();
    security.add(securityContext());
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.any())
            .build()
            .pathMapping("/").securityContexts(security);
}

private SecurityContext securityContext() {
    return SecurityContext.builder()
            .forPaths(PathSelectors.regex("/"))
            .build();
 }
}
Run Code Online (Sandbox Code Playgroud)

下面是我的WebConfig.xml

@EnableWebMvc
@Configuration
@Import(SwaggerConfiguration.class)
@ComponentScan("com.bank.direct.services")

public class WebConfig extends WebMvcConfigurerAdapter {


@Override …
Run Code Online (Sandbox Code Playgroud)

rest swagger swagger-ui spring-4 swagger-2.0

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

Spring应用程序:为什么swagger-ui无法在swagger-resources/configuration/ui上执行HTTP GET?

我一直试图用我的Spring REST应用程序设置swagger-ui.我使用的是弹簧4.2.6.RELEASE和swagger core&ui 2.5.0.我没有使用昂首阔步的注释,期望能够大摇大摆地获取Spring REST注释.

我可以大摇大摆来生成api文档,我可以在v2/api-docs下查看它.

我能够点击swagger-ui.html页面,但它没有在页面上显示任何api-docs或控制器信息.在浏览器上启用调试器模式时,我发现在尝试获取"swagger-resources/configuration/ui"时出错是错误的 - 返回404(未找到).

我按照以下链接设置了swagger-ui http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

我最初设置了上面链接中指定的资源处理程序,但这也没有帮助,并给了我相同的404错误.我已经尝试调整资源处理程序,所以看看它是否有助于swagger-ui对swagger-resources/configuration/ui进行GET.

为什么swagger-ui无法获取资源swagger-resources/configuration/ui?

我已经设置了我的资源处理程序,如下所示.

SwaggerConfiguration

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

@Bean
public Docket api(){
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.any())
            .build();
            //.apiInfo(apiInfo());
}
}
Run Code Online (Sandbox Code Playgroud)

Web配置文件

@EnableWebMvc
@Configuration
@Import(SwaggerConfiguration.class)
@ComponentScan("com.bank.direct.services")

public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> pConverters) {
    pConverters.add(RestUtils.getJSONMessageConverter());
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("**/**").addResourceLocations("classpath:/META-INF/resources/");
    registry
    .addResourceHandler("swagger-ui.html")
    .addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
    registry
    .addResourceHandler("/webjars/**")
    .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
Run Code Online (Sandbox Code Playgroud)

}

我确实为webapp设置了SecurityConfig,但是我已经将它保持在最低限度,以防它可能导致任何问题.

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter …
Run Code Online (Sandbox Code Playgroud)

rest spring swagger swagger-ui swagger-2.0

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

Flyway 没有拿起我的 sql 文件进行迁移

我正在使用 Flyway 版本 4.1.2

我有一个名为 SAPDATA 的模式。我正在寻找执行以下脚本 V0.0.1_1__baseline.sql 。我看到我的 sql 文件被 flyway 忽略了,它过滤了我的资源。

我已经在架构中有表,所以我将基线 OnMigrate 设置为 true 以迁移我的脚本。

请您告诉我是否应该明确设置架构名称?我不知道为什么我的 sql 文件被过滤掉了?

请你告诉我是否在我的飞行路线上遗漏了任何特定的设置,以便我的 sql 得到执行?

执行代码

      @Override
        protected void doOperation(DatabaseConfig.DataSourceConfig databaseConfig, String location) {
            final Flyway flyway = new Flyway();
            flyway.setLocations(location);
            flyway.setDataSource(databaseConfig.getUrl(), databaseConfig.getUsername(), databaseConfig.getPassword());
           flyway.setBaselineOnMigrate(true);
           flyway.migrate();
        }

**Execution logs**
 17:51:46.073 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - Spring Jdbc available: false
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.callback.SqlScriptFlywayCallback - Scanning for SQL callbacks ...
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning for classpath resources at 'classpath:db/migration/sap' (Prefix: '', …
Run Code Online (Sandbox Code Playgroud)

java flyway

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

为什么在$ in in typescript中使用返回tick

我正在经历角度的turorial,我看到下面

https://angular.io/tutorial/toh-pt6

const url = `${this.heroesUrl}/${hero.id}`;
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么我需要在$ {之前使用`?因为这是打字稿和类似于javascript我不能使用

 this.heroesUrl + "/" + hero.id 
Run Code Online (Sandbox Code Playgroud)

为什么我需要使用返回tick和$ {操作?

typescript angular

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

angular 2 - ng build vs webpack build

我期待看到建立和部署我的角度2 Web应用程序的最佳方法是什么?

我终于需要将它作为web包资源提供给我的dropwizard应用程序.

  1. 我试图理解我是否应该保留构建并使用它来生成我的dist文件夹,或者我应该用webpack覆盖它并执行https://angular.io/guide/webpack中指定的任何内容.

  2. ng build内部调用webpack吗?如果是的话,设置我自己的webpack-config文件并按照https://angular.io/guide/webpack中的说明进行设置是否有任何好处.

webpack angular-cli angular

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

在ng build期间修改javascript脚本标记的src位置

我的index.html文件post ng build具有以下文件

<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="polyfills.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
Run Code Online (Sandbox Code Playgroud)

例如,如何在src文件夹位置中创建角度cli前置'app' src="/app/vendor.bundle.js"

我需要进行上述更改,因为我从以'/ app /'开头的文件系统位置加载dropwizard中的所有静态资源

下面是我的angular-cli.json供参考

角cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "web"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/primeng/resources/themes/ludvig/theme.css",
        "../node_modules/primeng/resources/primeng.min.css",
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

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

ng build --prod 对于 angular-cli.json 中指定的 outDir 没有给出此类文件或目录错误

当我尝试构建产品(ng build --prod)时,我的角度项目无法构建。请注意ng build似乎工作正常。

当我尝试使用 --prod 选项构建时出现以下错误

Error: ENOENT: no such file or directory, mkdir 'C:\dev\workspaces\intellij-workspaces\myproject\web\target\frontend'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:922:18)
Run Code Online (Sandbox Code Playgroud)

我已将 Angular-cli outDir 设置如下

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "web"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "../../../target/frontend",
      "deployUrl": "myproject-dashboard/",
      "assets": [
        "assets",
        "favicon.ico"
      ],
Run Code Online (Sandbox Code Playgroud)

我的 package.json 和 angular-cli.json 文件位于 myproject/web/src/main/frontend 下

因此,理想情况下,基于 angular-cli.json 中为 outDir 设置的相对路径,我希望在myproject/web文件夹下创建一个名为 target 的文件夹,并且我的所有构建输出都可以在那里使用。

请您告诉我是否应该手动创建目标文件夹,或者是否有办法告诉 angular-cli 自动创建它?

angular-cli angular

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

比较两个列表时忽略字段

我有两个 Person 对象列表。

Person class has the below attributes
String Name, 
Integer Age, 
String Department, 
Date CreatedTime,
String CreatedBy
Run Code Online (Sandbox Code Playgroud)

当我比较列表是否相等时,我不想比较 CreatedTime 和 CreatedBy 字段。

如何使用 Java 8 比较两个列表的相等性,并忽略 CreatedTime、CreatedBy 字段进行比较?

collections java-8

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