小编Dan*_*Dan的帖子

如何在没有交互式提示的情况下执行 Terraform 操作?

我如何能够执行以下命令:

terraform apply

#=>

. . .

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value:
Run Code Online (Sandbox Code Playgroud)

没有随后的交互式提示?

terraform

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

为什么在angular4中将下划线添加到typescript类的字段中?

我正在构建一个Angular4项目并使用IntelliJ.每当我创建一个新类,然后添加gettersetter.IDE会向字段添加下划线.

由于这种打字稿语法似乎被IDE自动识别,然后以这种方式创建字段,让我认为这是一种最佳实践,但我也读到这不应该这样做.

为什么IDE会这样做?我是否应该允许它为角度项目执行此操作?谢谢你的帮助!

在创建getter和setter之前

export class Test {


  hello:string;
  world:string;


}
Run Code Online (Sandbox Code Playgroud)

创建getter和setter之后

export class Test {


  private _hello:string;
  private _world:string;

  get hello(): string {
    return this._hello;
  }

  set hello(value: string) {
    this._hello = value;
  }

  get world(): string {
    return this._world;
  }

  set world(value: string) {
    this._world = value;
  }
}
Run Code Online (Sandbox Code Playgroud)

intellij-idea typescript angular

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

如何使用angular5和angular材质创建自定义颜色主题

我一直在关注如何创建自定义主题的角度/材料文档,跟随其他博客,并检查各种堆栈溢出类似的问题,但似乎无法使这工作.我有以下styles.css,angular-cli.json,theme.scss和另一个sass文件,其中我的主题颜色来自super-styles.sass.

styles.css的

...
@import 'assets/styles/theme.scss';
...
Run Code Online (Sandbox Code Playgroud)

角cli.json

...
"styles": [
   "styles.css",
    "src/assets/styles/theme.scss"
],
...
Run Code Online (Sandbox Code Playgroud)

theme.scss

@import '~@angular/material/theming';
@import "super-styles";

// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core()

// Define the palettes for your theme using the …
Run Code Online (Sandbox Code Playgroud)

material-design angular-material angular

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

如何在terraform中定义全局变量?

我正在开发一个 terraform 项目。在其中,我想要一个文件包含许多变量。我希望可以从项目的任何模块访问这些变量。我已经查看了文档和 udemy 课程,但仍然不知道如何做到这一点。在 Terraform 中如何做到这一点?谢谢!

terraform

16
推荐指数
3
解决办法
2万
查看次数

如何解决错误在使用react-native构建APK时无法执行aapt?

我已经构建了一个react-native应用程序.它在Android模拟器上工作正常,现在我想生成一个APK.我已经按照文档执行此操作,这里可以看到我使用命令

./gradlew assembleRelease

构建apk但我在构建APK时遇到错误.我已经检查了关于该主题的各种堆栈溢出问题,包括 这个也是这个github问题.我已经包括了这条线

android.enableAapt2 = FALSE

应用程序级build.gradle文件如下所示

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets  * and bundleReleaseJsAndAssets).  * These basically call `react-native bundle` with the correct arguments during the Android build  * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the  * bundle directly from the development server. Below you can see all the possible …
Run Code Online (Sandbox Code Playgroud)

android apk react-native

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

如何使用spring加载基于服务器环境的属性文件,以便可以注入值?

令我惊讶的是,我很难找到这个问题的答案.我看过很多例子,您可以使用@PropertySource为类加载特定的属性文件.我还看到了一些示例,您可以在Spring Boot项目中轻松添加不同的属性文件.但我想要做的是为一个非春季启动的spring项目执行此操作并加载属性文件,以便可以在使用@Component注释的类中注入此文件的值,该类取决于服务器环境.因此,例如,如果我在开发服务器上,我希望加载特定的属性文件,并在生产中使用不同的属性文件.我这样做的原因是因为我的数据和服务层是他们自己的模块.这些模块包含自己的单元测试,可以在其他Spring引导项目中作为自己的模块导入.我需要加载属性文件来为这些使用spring而不是spring boot的模块提供服务.我尝试了以下,但这不起作用.

@Configuration
@Profile("test")
@EnableJpaRepositories("com.hi.repository")
@EnableTransactionManagement
@EnableScheduling
public class InfrastructureConfig  {
...
    @Bean
    public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        Map<String, String> env = System.getenv();
        String propertiesFile=null;

        String e = env.get("SERVER_ENV");

        if (e.equals("dev")) {
            propertiesFile = "environment/development.properties";
        } else if (e.equals("prod")) {
            propertiesFile = "environment/production.properties";
        }

        configurer.setLocation(new ClassPathResource(propertiesFile));


        return configurer;

    }
Run Code Online (Sandbox Code Playgroud)

然后我有一个看起来像这样的测试

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/DealServiceTest-context.xml"})
@ActiveProfiles("test")
public class LogTest {

    private static final Logger log = LogManager.getLogger(LogTest.class);

    @Autowired
    PathsService pathsService;

    @Autowired
    Environment environment;


    @Test
    public …
Run Code Online (Sandbox Code Playgroud)

java spring

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

如何从另一个 dockercompose 文件运行一个 dockercompose 文件?

我查看了 docker 文档来寻找这个问题的答案,但我没有看到它被简单地放在任何地方。我想在 docker 中启动我的应用程序,使用docker-compose.yml我希望docker-compose.yml启动在docker-compose.yml不同项目的另一个文件中定义的其他容器。

version: '3.4'

#we need network if we want the services to talk to each other
networks:
  services:
    driver: bridge

services:

  jc:
    build:
      context: .
      dockerfile: ./Dockerfile
      args:
      - PORT=8080
      network: host
    networks:
    - services
    image: jc
    container_name: jc
    ports:
    - 8080:8080
Run Code Online (Sandbox Code Playgroud)

如何编辑此文件,以便docker-compose.yml在运行此文件时可以运行不同文件路径中的另一个文件docker-compose.yml

docker docker-compose

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

如何在angular2中模拟@Input()对象?

我查看了angular2网站,并检查了很多SO帖子,我找不到用例说明的例子.

我想模拟来自具有@Input()标记的对象的数据.我的组件看起来像这样

...
export class DriftInfoDisplayComponent implements OnInit {

  showThisDriftInfo:boolean;
  headerText:string;
  informationText:string;
  linkText:string;
  @Input() inputInfo:DriftInfo;

  constructor(){}

  ngOnInit() {
    this.headerText = this.inputInfo.headerText;
    this.informationText = this.inputInfo.informationText;
    this.linkText = this.inputInfo.linkText;
    this.showThisDriftInfo = this.inputInfo.visible;
  }

  toggleDriftInfo(){
    this.showThisDriftInfo = ! this.showThisDriftInfo;
  }
}
Run Code Online (Sandbox Code Playgroud)

我的这个组件的单元测试文件是这样的

describe('DriftInfoComponent', () => {
  let component: DriftInfoDisplayComponent;
  let fixture: ComponentFixture<DriftInfoDisplayComponent>;


  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ DriftInfoDisplayComponent ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(DriftInfoDisplayComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    const fixture = TestBed.createComponent(DriftInfoDisplayComponent); …
Run Code Online (Sandbox Code Playgroud)

karma-jasmine angular

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

在邮件请求正文中的Json对象中发送用户名和密码是否安全?

我正在构建一个Web应用程序,我的Web服务器是安全的,这意味着它使用前端的ssl证书来加密连接.

当用户登录时,会创建一个看起来像这样的JSON对象,并将其发送到服务器.

{
    username:"the user's username",
    password:"the user's password"
}
Run Code Online (Sandbox Code Playgroud)

在服务器上,使用使用salt的散列算法验证.一旦验证,就会创建一个有效一段时间的api令牌,并在标头中来回传递,以便在发出请求时验证用户.是发送这样的最佳做法/安全的用户名和密码,还是最好将它发送到标题?

security passwords json

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

可以使用ngOnInit初始化booking.com表格,但不能再次

所以我使用角度材料和angular4,我已经在一个MdDialogue组件中放入了html for booking.com表格.当有人按下按钮时,我希望这个对话框弹出窗体内部的形式.应用程序加载后,它会按预期工作一次,但不会再次.我希望每次都能工作.没有错误消息,因此我不清楚为什么会发生这种情况.booking()中的逻辑初始化表单.

booking.com表单的html如下所示.

<ins class="bookingaff" data-aid="1179852" data-target_aid="1179846" data-prod="nsb" data-width="100%" data-height="auto">
  <!-- Anything inside will go away once widget is loaded. -->
  <a href="//www.booking.com?aid=1179846">Booking.com</a>
</ins>
Run Code Online (Sandbox Code Playgroud)

这是booking.com组件的样子......

...
     openBookings(){
        let dialogRef = this.dialog.open(Booking_com);
        dialogRef.afterClosed().subscribe(result => {
        });
      }

      debug(data){
        console.log(data);
      }



    }

    @Component({
      selector: 'Booking_com',
      templateUrl: 'Booking_com.html',
      styleUrls: ['Booking_com.sass']
    })
    export class Booking_com implements AfterViewInit{


      ngAfterViewInit(): void {
        this.booking();
      }

      constructor(public dialogRef: MdDialogRef<Booking_com>) {}


      booking(){
        (function(d, sc, u) {
          var s:any =  d.createElement(sc);
          var p:any =  d.getElementsByTagName(sc)[0];
          s.type = 'text/javascript';
          s.async …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

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