问:
Ansible logging
I am having difficulty getting Ansible to perform logging. A simple YAML named demo5.yml spins up AWS EC2 instances (below). The following entry has been added into the ansible.cfg file:
log_pth=/var/log/ansible.log

The playbook YAML is executed by calling: ansible-playbook demo5.yml -v

There is nothing in the ansible.log after execution.

What am I doing incorrectly?

```<code>---
- name: Example of provisioning servers
  hosts: 127.0.0.1
  connection: local
  tasks:
   - name: Create security group
     local_action:
       module: ec2_group
       name: ep2
       description: Access to the Episode2 servers
       region: us-east-1
       rules:
         - proto: tcp
           from_port: 22
           to_port: 22
           cidr_ip: 0.0.0.0/0

   - name: Launch instances
     local_action:
       module: ec2
       instance_tags:
        Name: server1
        Env: statestreettest
       region: us-east-1
       keypair: ansiblekeypair
       group: ep2
       instance_type: m1.small
       image: ami-1aae3a0c
       count: 5
       wait: yes
     register: ec2
</code>```

Here is my ansible.cfg file:

```<code># config file for ansible -- https://ansible.com/
# ===============================================

# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]

# some basic default values...

#inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
#module_utils   = /usr/share/my_module_utils/
#remote_tmp     = ~/.ansible/tmp
#local_tmp      = ~/.ansible/tmp
#forks          = 5
#poll_interval  = 15
#sudo_user      = root
#ask_sudo_pass = True
#ask_pass      = True
#transport      = smart
#remote_port    = 22
#module_lang    = C
#module_set_locale = False
log_pth=/var/log/ansible.log

# plays will gather facts by default, which contain information about
# the remote system.
#
# smart - gather by default, but don't regather if already gathered
# implicit - gather by default, turn off with gather_facts: False
# explicit - do not gather by default, must say gather_facts: True
#gathering = implicit

# This only affects the gathering done by a play's gather_facts directive,
# by default gathering retrieves all facts subsets
# all - gather all subsets
# network - gather min and network facts
# hardware - gather hardware facts (longest facts to retrieve)
# virtual - gather min and virtual facts
# facter - import facts from facter
# ohai - import facts from ohai
# You can combine them using comma (ex: network,virtual)
# You can negate them using ! (ex: !hardware,!facter,!ohai)
# A minimal set of facts is always gathered.
#gather_subset = all

# some hardware related facts are collected
# with a maximum timeout of 10 seconds. This
# option lets you increase or decrease that
# timeout to something more suitable for the
# environment.
# gather_timeout = 10

# additional paths to search for roles in, colon separated
#roles_path    = /etc/ansible/roles

# uncomment this to disable SSH key host checking
#host_key_checking = False

# change the default callback
#stdout_callback = skippy
# enable additional callbacks
#callback_whitelist = timer, mail

# Determine whether includes in tasks and handlers are "static" by
# default. As of 2.0, includes are dynamic by default. Setting these
# values to True will make includes behave more like they did in the
# 1.x versions.
#task_includes_static = True
#handler_includes_static = True

# Controls if a missing handler for a notification event is an error or a warning
#error_on_missing_handler = True

# change this for alternative sudo implementations
#sudo_exe = sudo

# What flags to pass to sudo
# WARNING: leaving out the defaults might create unexpected behaviours
#sudo_flags = -H -S -n

# SSH timeout
#timeout = 10

# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
#remote_user = root

# logging is off by default unless this path is defined
# if so defined, consider logrotate
#log_path = /var/log/ansible.log

# default module name for /usr/bin/ansible
#module_name = command

# use this shell for commands executed under sudo
# you may need to change this to bin/bash in rare instances
# if sudo is constrained
#executable = /bin/sh

# if inventory variables overlap, does the higher precedence one win
# or are hash values merged together?  The default is 'replace' but
# this can also be set to 'merge'.
#hash_behaviour = replace

# by default, variables from roles will be visible in the global variable
# scope. To prevent this, the following option can be enabled, and only
# tasks and handlers within the role will see the variables there
#private_role_vars = yes

# list any Jinja2 extensions to enable here:
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n

# if set, always use this private key file for authentication, same as
# if passing --private-key to ansible or ansible-playbook
#private_key_file = /path/to/file

# If set, configures the path to the Vault password file as an alternative to
# specifying --vault-password-file on the command line.
#vault_password_file = /path/to/vault_password_file

# format of string {{ ansible_managed }} available within Jinja2
# templates indicates to users editing templates files will be replaced.
# replacing {file}, {host} and {uid} and strftime codes with proper values.
#ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
# {file}, {host}, {uid}, and the timestamp can all interfere with idempotence
# in some situations so the default is a static string:
#ansible_managed = Ansible managed

# by default, ansible-playbook will display "Skipping [host]" if it determines a task
# should not be run on a host.  Set this to "False" if you don't want to see these "Skipping"
# messages. NOTE: the task header will still be shown regardless of whether or not the
# task is skipped.
#display_skipped_hosts = True

# by default, if a task in a playbook does not include a name: field then
# ansible-playbook will construct a header that includes the task's action but
# not the task's args.  This is a security feature because ansible cannot know
# if the *module* considers an argument to be no_log at the time that the
# header is printed.  If your environment doesn't have a problem securing
# stdout from ansible-playbook (or you have manually specified no_log in your
# playbook on all of the tasks where you have secret information) then you can
# safely set this to True to get more informative messages.
#display_args_to_stdout = False

# by default (as of 1.3), Ansible will raise errors when attempting to dereference
# Jinja2 variables that are not set in templates or action lines. Uncomment this line
# to revert the behavior to pre-1.3.
#error_on_undefined_vars = False

# by default (as of 1.6), Ansible may display warnings based on the configuration of the
# system running ansible itself. This may include warnings about 3rd party packages or
# other conditions that should be resolved if possible.
# to disable these warnings, set the following value to False:
#system_warnings = True

# by default (as of 1.4), Ansible may display deprecation warnings for language
# features that should no longer be used and will be removed in future versions.
# to disable these warnings, set the following value to False:
#deprecation_warnings = True

# (as of 1.8), Ansible can optionally warn when usage of the shell and
# command module appear to be simplified by using a default Ansible module
# instead.  These warnings can be silenced by adjusting the following
# setting or adding warn=yes or warn=no to the end of the command line
# parameter string.  This will for example suggest using the git module
# instead of shelling out to the git command.
# command_warnings = False

# set plugin path directories here, separate with colons
#action_plugins     = /usr/share/ansible/plugins/action
#cache_plugins      = /usr/share/ansible/plugins/cache
#callback_plugins   = /usr/share/ansible/plugins/callback
#connection_plugins = /usr/share/ansible/plugins/connection
#lookup_plugins     = /usr/share/ansible/plugins/lookup
#inventory_plugins  = /usr/share/ansible/plugins/inventory
#vars_plugins       = /usr/share/ansible/plugins/vars
#filter_plugins     = /usr/share/ansible/plugins/filter
#test_plugins       = /usr/share/ansible/plugins/test
#terminal_plugins   = /usr/share/ansible/plugins/terminal
#strategy_plugins   = /usr/share/ansible/plugins/strategy

# by default, ansible will use the 'linear' strategy but you may want to try
# another one
#strategy = free

# by default callbacks are not loaded for /bin/ansible, enable this if you
# want, for example, a notification or logging callback to also apply to
# /bin/ansible runs
#bin_ansible_callbacks = False

# don't like cows?  that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
#nocows = 1

# set which cowsay stencil you'd like to use by default. When set to 'random',
# a random stencil will be selected for each task. The selection will be filtered
# against the `cow_whitelist` option below.
#cow_selection = default
#cow_selection = random

# when using the 'random' option for cowsay, stencils will be restricted to this list.
# it should be formatted as a comma-separated list with no spaces between names.
# NOTE: line continuations here are for formatting purposes only, as the INI parser
#       in python does not support them.
#cow_whitelist=bud-frogs,bunny,cheese,daemon,default,dragon,elephant-in-snake,elephant,eyes,\
#              hellokitty,kitty,luke-koala,meow,milk,moofasa,moose,ren,sheep,small,stegosaurus,\
#              stimpy,supermilker,three-eyes,turkey,turtle,tux,udder,vader-koala,vader,www

# don't like colors either?
# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1
#nocolor = 1

# if set to a persistent type (not 'memory', for example 'redis') fact values
# from previous runs in Ansible will be stored.  This may be useful when
# wanting to use, for example, IP information from one group of servers
# without having to talk to them in the same playbook run to get their
# current IP information.
#fact_caching = memory

# retry files
# When a playbook fails by default a .retry file will be created in ~/
# You can disable this feature by setting retry_files_enabled to False
# and you can change the location of the files by setting retry_files_save_path

#retry_files_enabled = False
#retry_files_save_path = ~/.ansible-retry

# squash actions
# Ansible can optimise actions that call modules with list parameters
# when looping. Instead of calling the module once per with_ item, the
# module is called once with all items at once. Currently this only works
# under limited circumstances, and only with parameters named 'name'.
#squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper

# prevents logging of task data, off by default
#no_log = False

# prevents logging of tasks, but only on the targets, data is still logged on the master/controller
#no_target_syslog = False

# controls whether Ansible will raise an error or warning if a task has no
# choice but to create world readable temporary files to execute a module on
# the remote machine.  This option is False by default for security.  Users may
# turn this on to have behaviour more like Ansible prior to 2.1.x.  See
# https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user
# for more secure ways to fix this than enabling this option.
#allow_world_readable_tmpfiles = False

# controls the compression level of variables sent to
# worker processes. At the default of 0, no compression
# is used. This value must be an integer from 0 to 9.
#var_compression_level = 9

# controls what compression method is used for new-style ansible modules when
# they are sent to the remote system.  The compression types depend on having
# support compiled into both the controller's python and the client's python.
# The names should match with the python Zipfile compression types:
# * ZIP_STORED (no compression. available everywhere)
# * ZIP_DEFLATED (uses zlib, the default)
# These values may be set per host via the ansible_module_compression inventory
# variable
#module_compression = 'ZIP_DEFLATED'

# This controls the cutoff point (in bytes) on --diff for files
# set to 0 for unlimited (RAM may suffer!).
#max_diff_size = 1048576

# This controls how ansible handles multiple --tags and --skip-tags arguments
# on the CLI.  If this is True then multiple arguments are merged together.  If
# it is False, then the last specified argument is used and the others are ignored.
#merge_multiple_cli_flags = False

# Controls showing custom stats at the end, off by default
#show_custom_stats = True

# Controlls which files to ignore when using a directory as inventory with
# possibly multiple sources (both static and dynamic)
#inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo

# This family of modules use an alternative execution path optimized for network appliances
# only update this setting if you know how this works, otherwise it can break module execution
#network_group_modules=['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos']

[privilege_escalation]
#become=True
#become_method=sudo
#become_user=root
#become_ask_pass=False

[paramiko_connection]

# uncomment this line to cause the paramiko connection plugin to not record new host
# keys encountered.  Increases performance on new host additions.  Setting works independently of the
# host key checking setting above.
#record_host_keys=False

# by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this
# line to disable this behaviour.
#pty=False

# paramiko will default to looking for SSH keys initially when trying to
# authenticate to remote devices.  This is a problem for some network devices
# that close the connection after a key failure.  Uncomment this line to
# disable the Paramiko look for keys function
#look_for_keys = False

# When using persistent connections with Paramiko, the connection runs in a
# background process.  If the host doesn't already have a valid SSH key, by
# default Ansible will prompt to add the host key.  This will cause connections
# running in background processes to fail.  Uncomment this line to have
# Paramiko automatically add host keys.
#host_key_auto_add = True

[ssh_connection]

# ssh arguments to use
# Leaving off ControlPersist will result in poor performance, so use
# paramiko on older platforms rather than removing it, -C controls compression use
#ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s

# The base directory for the ControlPath sockets.
# This is the "%(directory)s" in the control_path option
#
# Example:
# control_path_dir = /tmp/.ansible/cp
#control_path_dir = ~/.ansible/cp

# The path to use for the ControlPath sockets. This defaults to a hashed string of the hostname,
# port and username (empty string in the config). The hash mitigates a common problem users
# found with long hostames and the conventional %(directory)s/ansible-ssh-%%h-%%p-%%r format.
# In those cases, a "too long for Unix domain socket" ssh error would occur.
#
# Example:
# control_path = %(directory)s/%%h-%%r
#control_path =

# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
# By default, this option is disabled to preserve compatibility with
# sudoers configurations that have requiretty (the default on many distros).
#
#pipelining = False

# Control the mechanism for transferring files (old)
#   * smart = try sftp and then try scp [default]
#   * True = use scp only
#   * False = use sftp only
#scp_if_ssh = smart

# Control the mechanism for transferring files (new)
# If set, this will override the scp_if_ssh option
#   * sftp  = use sftp to transfer files
#   * scp   = use scp to transfer files
#   * piped = use 'dd' over SSH to transfer files
#   * smart = try sftp, scp, and piped, in that order [default]
#transfer_method = smart

# if False, sftp will not use batch mode to transfer files. This may cause some
# types of file transfer failures impossible to catch however, and should
# only be disabled if your sftp version has problems with batch mode
#sftp_batch_mode = False

[persistent_connection]

# Configures the persistent connection timeout value in seconds.  This value is
# how long the persistent connection will remain idle before it is destroyed.
# If the connection doesn't receive a request before the timeout value
# expires, the connection is shutdown.  The default value is 30 seconds.
connect_timeout = 30

# Configures the persistent connection retries.  This value configures the
# number of attempts the ansible-connection will make when trying to connect
# to the local domain socket.  The default value is 30.
connect_retries = 30

# Configures the amount of time in seconds to wait between connection attempts
# to the local unix domain socket.  This value works in conjunction with the
# connect_retries value to define how long to try to connect to the local
# domain socket when setting up a persistent connection.  The default value is
# 1 second.
connect_interval = 1

[accelerate]
#accelerate_port = 5099
#accelerate_timeout = 30
#accelerate_connect_timeout = 5.0

# The daemon timeout is measured in minutes. This time is measured
# from the last activity to the accelerate daemon.
#accelerate_daemon_timeout = 30

# If set to yes, accelerate_multi_key will allow multiple
# private keys to be uploaded to it, though each user must
# have access to the system via SSH to add a new key. The default
# is "no".
#accelerate_multi_key = yes

[selinux]
# file systems that require special treatment when dealing with security context
# the default behaviour that copies the existing context or uses the user default
# needs to be changed to use the file system dependent context.
#special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p

# Set this to yes to allow libvirt_lxc connections to work without SELinux.
#libvirt_lxc_noseclabel = yes

[colors]
#highlight = white
#verbose = blue
#warn = bright purple
#error = red
#debug = dark gray
#deprecate = purple
#skip = cyan
#unreachable = red
#ok = green
#changed = yellow
#diff_add = green
#diff_remove = red
#diff_lines = cyan

[diff]
# Always print diff when running ( same as always running with -D/--diff )
# always = no

# Set how many context lines to show in diff
# context = 3
</code>```

答: The parameter name is log_path, not log_pth.

Title: Ansible logging

Body:
I am having difficulty getting Ansible to perform logging. A simple YAML named demo5.yml spins up AWS EC2 instances (below). The following entry has been added into the ansible.cfg file:
log_pth=/var/log/ansible.log

The playbook YAML is executed by calling: ansible-playbook demo5.yml -v

There is nothing in the ansible.log after execution.

What am I doing incorrectly?

---
- name: Example of provisioning servers
  hosts: 127.0.0.1
  connection: local
  tasks:
   - name: Create security group
     local_action:
       module: ec2_group
       name: ep2
       description: Access to the Episode2 servers
       region: us-east-1
       rules:
         - proto: tcp
           from_port: 22
           to_port: 22
           cidr_ip: 0.0.0.0/0

   - name: Launch instances
     local_action:
       module: ec2
       instance_tags:
        Name: server1
        Env: statestreettest
       region: us-east-1
       keypair: ansiblekeypair
       group: ep2
       instance_type: m1.small
       image: ami-1aae3a0c
       count: 5
       wait: yes
     register: ec2

Here is my ansible.cfg file:

# config file for ansible -- https://ansible.com/
# ===============================================

# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]

# some basic default values...

#inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
#module_utils   = /usr/share/my_module_utils/
#remote_tmp     = ~/.ansible/tmp
#local_tmp      = ~/.ansible/tmp
#forks          = 5
#poll_interval  = 15
#sudo_user      = root
#ask_sudo_pass = True
#ask_pass      = True
#transport      = smart
#remote_port    = 22
#module_lang    = C
#module_set_locale = False
log_pth=/var/log/ansible.log

# plays will gather facts by default, which contain information about
# the remote system.
#
# smart - gather by default, but don't regather if already gathered
# implicit - gather by default, turn off with gather_facts: False
# explicit - do not gather by default, must say gather_facts: True
#gathering = implicit

# This only affects the gathering done by a play's gather_facts directive,
# by default gathering retrieves all facts subsets
# all - gather all subsets
# network - gather min and network facts
# hardware - gather hardware facts (longest facts to retrieve)
# virtual - gather min and virtual facts
# facter - import facts from facter
# ohai - import facts from ohai
# You can combine them using comma (ex: network,virtual)
# You can negate them using ! (ex: !hardware,!facter,!ohai)
# A minimal set of facts is always gathered.
#gather_subset = all

# some hardware related facts are collected
# with a maximum timeout of 10 seconds. This
# option lets you increase or decrease that
# timeout to something more suitable for the
# environment.
# gather_timeout = 10

# additional paths to search for roles in, colon separated
#roles_path    = /etc/ansible/roles

# uncomment this to disable SSH key host checking
#host_key_checking = False

# change the default callback
#stdout_callback = skippy
# enable additional callbacks
#callback_whitelist = timer, mail

# Determine whether includes in tasks and handlers are "static" by
# default. As of 2.0, includes are dynamic by default. Setting these
# values to True will make includes behave more like they did in the
# 1.x versions.
#task_includes_static = True
#handler_includes_static = True

# Controls if a missing handler for a notification event is an error or a warning
#error_on_missing_handler = True

# change this for alternative sudo implementations
#sudo_exe = sudo

# What flags to pass to sudo
# WARNING: leaving out the defaults might create unexpected behaviours
#sudo_flags = -H -S -n

# SSH timeout
#timeout = 10

# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
#remote_user = root

# logging is off by default unless this path is defined
# if so defined, consider logrotate
#log_path = /var/log/ansible.log

# default module name for /usr/bin/ansible
#module_name = command

# use this shell for commands executed under sudo
# you may need to change this to bin/bash in rare instances
# if sudo is constrained
#executable = /bin/sh

# if inventory variables overlap, does the higher precedence one win
# or are hash values merged together?  The default is 'replace' but
# this can also be set to 'merge'.
#hash_behaviour = replace

# by default, variables from roles will be visible in the global variable
# scope. To prevent this, the following option can be enabled, and only
# tasks and handlers within the role will see the variables there
#private_role_vars = yes

# list any Jinja2 extensions to enable here:
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n

# if set, always use this private key file for authentication, same as
# if passing --private-key to ansible or ansible-playbook
#private_key_file = /path/to/file

# If set, configures the path to the Vault password file as an alternative to
# specifying --vault-password-file on the command line.
#vault_password_file = /path/to/vault_password_file

# format of string {{ ansible_managed }} available within Jinja2
# templates indicates to users editing templates files will be replaced.
# replacing {file}, {host} and {uid} and strftime codes with proper values.
#ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
# {file}, {host}, {uid}, and the timestamp can all interfere with idempotence
# in some situations so the default is a static string:
#ansible_managed = Ansible managed

# by default, ansible-playbook will display "Skipping [host]" if it determines a task
# should not be run on a host.  Set this to "False" if you don't want to see these "Skipping"
# messages. NOTE: the task header will still be shown regardless of whether or not the
# task is skipped.
#display_skipped_hosts = True

# by default, if a task in a playbook does not include a name: field then
# ansible-playbook will construct a header that includes the task's action but
# not the task's args.  This is a security feature because ansible cannot know
# if the *module* considers an argument to be no_log at the time that the
# header is printed.  If your environment doesn't have a problem securing
# stdout from ansible-playbook (or you have manually specified no_log in your
# playbook on all of the tasks where you have secret information) then you can
# safely set this to True to get more informative messages.
#display_args_to_stdout = False

# by default (as of 1.3), Ansible will raise errors when attempting to dereference
# Jinja2 variables that are not set in templates or action lines. Uncomment this line
# to revert the behavior to pre-1.3.
#error_on_undefined_vars = False

# by default (as of 1.6), Ansible may display warnings based on the configuration of the
# system running ansible itself. This may include warnings about 3rd party packages or
# other conditions that should be resolved if possible.
# to disable these warnings, set the following value to False:
#system_warnings = True

# by default (as of 1.4), Ansible may display deprecation warnings for language
# features that should no longer be used and will be removed in future versions.
# to disable these warnings, set the following value to False:
#deprecation_warnings = True

# (as of 1.8), Ansible can optionally warn when usage of the shell and
# command module appear to be simplified by using a default Ansible module
# instead.  These warnings can be silenced by adjusting the following
# setting or adding warn=yes or warn=no to the end of the command line
# parameter string.  This will for example suggest using the git module
# instead of shelling out to the git command.
# command_warnings = False

# set plugin path directories here, separate with colons
#action_plugins     = /usr/share/ansible/plugins/action
#cache_plugins      = /usr/share/ansible/plugins/cache
#callback_plugins   = /usr/share/ansible/plugins/callback
#connection_plugins = /usr/share/ansible/plugins/connection
#lookup_plugins     = /usr/share/ansible/plugins/lookup
#inventory_plugins  = /usr/share/ansible/plugins/inventory
#vars_plugins       = /usr/share/ansible/plugins/vars
#filter_plugins     = /usr/share/ansible/plugins/filter
#test_plugins       = /usr/share/ansible/plugins/test
#terminal_plugins   = /usr/share/ansible/plugins/terminal
#strategy_plugins   = /usr/share/ansible/plugins/strategy

# by default, ansible will use the 'linear' strategy but you may want to try
# another one
#strategy = free

# by default callbacks are not loaded for /bin/ansible, enable this if you
# want, for example, a notification or logging callback to also apply to
# /bin/ansible runs
#bin_ansible_callbacks = False

# don't like cows?  that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
#nocows = 1

# set which cowsay stencil you'd like to use by default. When set to 'random',
# a random stencil will be selected for each task. The selection will be filtered
# against the `cow_whitelist` option below.
#cow_selection = default
#cow_selection = random

# when using the 'random' option for cowsay, stencils will be restricted to this list.
# it should be formatted as a comma-separated list with no spaces between names.
# NOTE: line continuations here are for formatting purposes only, as the INI parser
#       in python does not support them.
#cow_whitelist=bud-frogs,bunny,cheese,daemon,default,dragon,elephant-in-snake,elephant,eyes,\
#              hellokitty,kitty,luke-koala,meow,milk,moofasa,moose,ren,sheep,small,stegosaurus,\
#              stimpy,supermilker,three-eyes,turkey,turtle,tux,udder,vader-koala,vader,www

# don't like colors either?
# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1
#nocolor = 1

# if set to a persistent type (not 'memory', for example 'redis') fact values
# from previous runs in Ansible will be stored.  This may be useful when
# wanting to use, for example, IP information from one group of servers
# without having to talk to them in the same playbook run to get their
# current IP information.
#fact_caching = memory

# retry files
# When a playbook fails by default a .retry file will be created in ~/
# You can disable this feature by setting retry_files_enabled to False
# and you can change the location of the files by setting retry_files_save_path

#retry_files_enabled = False
#retry_files_save_path = ~/.ansible-retry

# squash actions
# Ansible can optimise actions that call modules with list parameters
# when looping. Instead of calling the module once per with_ item, the
# module is called once with all items at once. Currently this only works
# under limited circumstances, and only with parameters named 'name'.
#squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper

# prevents logging of task data, off by default
#no_log = False

# prevents logging of tasks, but only on the targets, data is still logged on the master/controller
#no_target_syslog = False

# controls whether Ansible will raise an error or warning if a task has no
# choice but to create world readable temporary files to execute a module on
# the remote machine.  This option is False by default for security.  Users may
# turn this on to have behaviour more like Ansible prior to 2.1.x.  See
# https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user
# for more secure ways to fix this than enabling this option.
#allow_world_readable_tmpfiles = False

# controls the compression level of variables sent to
# worker processes. At the default of 0, no compression
# is used. This value must be an integer from 0 to 9.
#var_compression_level = 9

# controls what compression method is used for new-style ansible modules when
# they are sent to the remote system.  The compression types depend on having
# support compiled into both the controller's python and the client's python.
# The names should match with the python Zipfile compression types:
# * ZIP_STORED (no compression. available everywhere)
# * ZIP_DEFLATED (uses zlib, the default)
# These values may be set per host via the ansible_module_compression inventory
# variable
#module_compression = 'ZIP_DEFLATED'

# This controls the cutoff point (in bytes) on --diff for files
# set to 0 for unlimited (RAM may suffer!).
#max_diff_size = 1048576

# This controls how ansible handles multiple --tags and --skip-tags arguments
# on the CLI.  If this is True then multiple arguments are merged together.  If
# it is False, then the last specified argument is used and the others are ignored.
#merge_multiple_cli_flags = False

# Controls showing custom stats at the end, off by default
#show_custom_stats = True

# Controlls which files to ignore when using a directory as inventory with
# possibly multiple sources (both static and dynamic)
#inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo

# This family of modules use an alternative execution path optimized for network appliances
# only update this setting if you know how this works, otherwise it can break module execution
#network_group_modules=['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos']

[privilege_escalation]
#become=True
#become_method=sudo
#become_user=root
#become_ask_pass=False

[paramiko_connection]

# uncomment this line to cause the paramiko connection plugin to not record new host
# keys encountered.  Increases performance on new host additions.  Setting works independently of the
# host key checking setting above.
#record_host_keys=False

# by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this
# line to disable this behaviour.
#pty=False

# paramiko will default to looking for SSH keys initially when trying to
# authenticate to remote devices.  This is a problem for some network devices
# that close the connection after a key failure.  Uncomment this line to
# disable the Paramiko look for keys function
#look_for_keys = False

# When using persistent connections with Paramiko, the connection runs in a
# background process.  If the host doesn't already have a valid SSH key, by
# default Ansible will prompt to add the host key.  This will cause connections
# running in background processes to fail.  Uncomment this line to have
# Paramiko automatically add host keys.
#host_key_auto_add = True

[ssh_connection]

# ssh arguments to use
# Leaving off ControlPersist will result in poor performance, so use
# paramiko on older platforms rather than removing it, -C controls compression use
#ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s

# The base directory for the ControlPath sockets.
# This is the "%(directory)s" in the control_path option
#
# Example:
# control_path_dir = /tmp/.ansible/cp
#control_path_dir = ~/.ansible/cp

# The path to use for the ControlPath sockets. This defaults to a hashed string of the hostname,
# port and username (empty string in the config). The hash mitigates a common problem users
# found with long hostames and the conventional %(directory)s/ansible-ssh-%%h-%%p-%%r format.
# In those cases, a "too long for Unix domain socket" ssh error would occur.
#
# Example:
# control_path = %(directory)s/%%h-%%r
#control_path =

# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
# By default, this option is disabled to preserve compatibility with
# sudoers configurations that have requiretty (the default on many distros).
#
#pipelining = False

# Control the mechanism for transferring files (old)
#   * smart = try sftp and then try scp [default]
#   * True = use scp only
#   * False = use sftp only
#scp_if_ssh = smart

# Control the mechanism for transferring files (new)
# If set, this will override the scp_if_ssh option
#   * sftp  = use sftp to transfer files
#   * scp   = use scp to transfer files
#   * piped = use 'dd' over SSH to transfer files
#   * smart = try sftp, scp, and piped, in that order [default]
#transfer_method = smart

# if False, sftp will not use batch mode to transfer files. This may cause some
# types of file transfer failures impossible to catch however, and should
# only be disabled if your sftp version has problems with batch mode
#sftp_batch_mode = False

[persistent_connection]

# Configures the persistent connection timeout value in seconds.  This value is
# how long the persistent connection will remain idle before it is destroyed.
# If the connection doesn't receive a request before the timeout value
# expires, the connection is shutdown.  The default value is 30 seconds.
connect_timeout = 30

# Configures the persistent connection retries.  This value configures the
# number of attempts the ansible-connection will make when trying to connect
# to the local domain socket.  The default value is 30.
connect_retries = 30

# Configures the amount of time in seconds to wait between connection attempts
# to the local unix domain socket.  This value works in conjunction with the
# connect_retries value to define how long to try to connect to the local
# domain socket when setting up a persistent connection.  The default value is
# 1 second.
connect_interval = 1

[accelerate]
#accelerate_port = 5099
#accelerate_timeout = 30
#accelerate_connect_timeout = 5.0

# The daemon timeout is measured in minutes. This time is measured
# from the last activity to the accelerate daemon.
#accelerate_daemon_timeout = 30

# If set to yes, accelerate_multi_key will allow multiple
# private keys to be uploaded to it, though each user must
# have access to the system via SSH to add a new key. The default
# is "no".
#accelerate_multi_key = yes

[selinux]
# file systems that require special treatment when dealing with security context
# the default behaviour that copies the existing context or uses the user default
# needs to be changed to use the file system dependent context.
#special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p

# Set this to yes to allow libvirt_lxc connections to work without SELinux.
#libvirt_lxc_noseclabel = yes

[colors]
#highlight = white
#verbose = blue
#warn = bright purple
#error = red
#debug = dark gray
#deprecate = purple
#skip = cyan
#unreachable = red
#ok = green
#changed = yellow
#diff_add = green
#diff_remove = red
#diff_lines = cyan

[diff]
# Always print diff when running ( same as always running with -D/--diff )
# always = no

# Set how many context lines to show in diff
# context = 3


来源: stackexchange

问:
What do I need to offset the performance setback induced by use of the Spring framework?
I am using Spring with Hibernate to create an Enterprise application.

Now, due to the abstractions given by the framework to the underlying J2EE
architecture, there is obviously going to be a runtime performance hit on my app.

What I need to know is a set of factors that I need to consider to make a decision about the minimum specs(Proc speed + RAM etc) that I need for a single host server of the application running RedHat Linux 3+ and devoted to running this application only, that would produce an efficiency score of say 8 out of 10 given a simultaneous-access-userbase increase of 100 per month.

No clustering is to be used.

答: Spring is typically used to create long-lived objects shortly after the application starts. There is virtually no performance cost over the life of the process.</p>

OwnerDisplayName: Lonzo

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: lindelof


问:
Where is SVN caching the hostname?
When I perform a SVN checkout and specify a hostname, SVN is attempting to resolve a hostname to an old repo that I no longer use. I cannot find where this old hostname (codespaces.com) is being cached.

Checkout from http://mysubdomain.unfuddle.com/svn/, revision HEAD, Fully recursive, Externals included
OPTIONS of 'http://mysubdomain.unfuddle.com/svn/': Could not resolve
hostname `https://svn.codespaces.com/my-old-project/': The requested name is valid,
but no data of the requested type was found.
 (http://mysubdomain.unfuddle.com)

I have uninstalled TortoiseSVN and SVN itself. And reinstalled them one by one. I have searched the C drive and the registry for the string literal codespaces.com - to no avail.

This has had me banging my head on the table for 2 full days and I am at my wits end. Can anybody shed some light on how to resolve this issue?

答: The host is stored in .svn/entries.

Title: Where is SVN caching the hostname?

Body: The host is stored in .svn/entries.


问:
rvm and rubygems issues after upgrading rubygems
I updated ruby gems with the following command:

```<code>gem update --system
</code>```

Now I get the following error when running bundle install or just about any other gem command such as gem -v

```<code>/Users/darrenburgess/.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:17:in `require': cannot load such file -- stringio (LoadError)
</code>```

I can switch to the system ruby with rvm use system, and then gem commands seem to work, but I get the same error when I run rvm use 2.0.0 even though the output of rvm list shows =* ruby-2.0.0-p648 [ x86_64 ] as the current and default. Note that I can switch to other installed version of ruby such as 2.4.1 and 2.1.2.

When using system ruby the version of gem is 2.0.14.1

The version of RVM installed is 1.29.2 (current latest).

Output of which -a ruby
    /Users/darrenburgess/.rvm/rubies/ruby-2.0.0-p648/bin/ruby
    /usr/bin/ruby
    /Users/darrenburgess/.rbenv/shims/ruby

Per other issues that are similar I checked to make sure that the RVM directory is first in my $PATH variable. This path is first in line:

```<code>/Users/darrenburgess/.rvm/gems/ruby-2.0.0-p648/bin
</code>```

Unfortunately I am deeply into knows enough to be dangerous territory here. I believe what may be happening is that I have introduced incompatibility between my installed version of ruby/rubygems/rvm.

At this point I need help with different avenues to explore. Thank you.

UPDATE:
I have 3 versions of Ruby 2.0.0 installed as per rvm list

```<code>ruby-2.0.0-p481 [ x86_64 ]
=* ruby-2.0.0-p643 [ x86_64 ]
ruby-2.0.0-p648 [ x86_64 ]
</code>```

I simply switched to using p643 and that fixed the issue, in so much as I am not using the trashed version of ruby == ruby-2.0.0-p648

So I guess at this point I have sidestepped the issue and the question now is simply what is wrong with ruby-2.0.0-p648 and how can it be fixed?

More information:
ruby-2.0.0-p643 is using gem version 2.4.6
ruby-2.0.0-p481 is using gem version 2.2.2
The current latest version of rubygems is 2.6.12

So I suspect that I upgraded rubygems to a version incompatible with ruby 2.0.0.

答:
I did manage to fix the issue, but I am still uncertain as to why upgrading rubygems caused these issues.

Fix was to:

```<code>rvm remove ruby-2.0.0-p648
rvm install ruby-2.0.0-p648
gem install bundler
bundle install
</code>```

So it seems removing the ruby version removes all of the installed gems and perhaps also the incompatible version of rubygems that I installed. Reinstalling ruby 2.0.0p648 resolved the issue.

ContentLicense: CC BY-SA 3.0

Body:
I updated ruby gems with the following command:

gem update --system

Now I get the following error when running bundle install or just about any other gem command such as gem -v

/Users/darrenburgess/.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:17:in `require': cannot load such file -- stringio (LoadError)

I can switch to the system ruby with rvm use system, and then gem commands seem to work, but I get the same error when I run rvm use 2.0.0 even though the output of rvm list shows =* ruby-2.0.0-p648 [ x86_64 ] as the current and default. Note that I can switch to other installed version of ruby such as 2.4.1 and 2.1.2.

When using system ruby the version of gem is 2.0.14.1

The version of RVM installed is 1.29.2 (current latest).

Output of which -a ruby
    /Users/darrenburgess/.rvm/rubies/ruby-2.0.0-p648/bin/ruby
    /usr/bin/ruby
    /Users/darrenburgess/.rbenv/shims/ruby

Per other issues that are similar I checked to make sure that the RVM directory is first in my $PATH variable. This path is first in line:

/Users/darrenburgess/.rvm/gems/ruby-2.0.0-p648/bin

Unfortunately I am deeply into knows enough to be dangerous territory here. I believe what may be happening is that I have introduced incompatibility between my installed version of ruby/rubygems/rvm.

At this point I need help with different avenues to explore. Thank you.

UPDATE:
I have 3 versions of Ruby 2.0.0 installed as per rvm list

ruby-2.0.0-p481 [ x86_64 ]
=* ruby-2.0.0-p643 [ x86_64 ]
ruby-2.0.0-p648 [ x86_64 ]

I simply switched to using p643 and that fixed the issue, in so much as I am not using the trashed version of ruby == ruby-2.0.0-p648

So I guess at this point I have sidestepped the issue and the question now is simply what is wrong with ruby-2.0.0-p648 and how can it be fixed?

More information:
ruby-2.0.0-p643 is using gem version 2.4.6
ruby-2.0.0-p481 is using gem version 2.2.2
The current latest version of rubygems is 2.6.12

So I suspect that I upgraded rubygems to a version incompatible with ruby 2.0.0.

Body:
I did manage to fix the issue, but I am still uncertain as to why upgrading rubygems caused these issues.

Fix was to:

rvm remove ruby-2.0.0-p648
rvm install ruby-2.0.0-p648
gem install bundler
bundle install

So it seems removing the ruby version removes all of the installed gems and perhaps also the incompatible version of rubygems that I installed. Reinstalling ruby 2.0.0p648 resolved the issue.


问:
ActionFilterAttribute on Web api call does not correctly redirect to the new location
My action filter attribute does not redirect to the new url i have defined:

```<code>public class RunOnServerAttribute : System.Web.Http.Filters.ActionFilterAttribute
{
    public ServerType Type;

    public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext filterContext)
    {
        switch (Type)
        {
            case ServerType.CMS:
                if (!filterContext.Request.RequestUri.AbsoluteUri.StartsWith(Config.CMSUrl))
                {
                    Uri correctedUri = new Uri($"{Config.CMSUrl.TrimEnd('/')}/{filterContext.Request.RequestUri.PathAndQuery.TrimStart('/')}");
                    var response = filterContext.Request.CreateResponse(System.Net.HttpStatusCode.Moved);
                    response.Headers.Location = correctedUri;
                    return;
                    // This does not seem to work
                }

                break;
        }

        base.OnActionExecuting(filterContext);
    }
}
</code>```

It just continues on with the normal request. I am debugging this by inspecting the Request.RequestUri in the executing api method

答: OnActionExecuting is called before controller action method invoking, so after running filter method controller action replaces response. I think method OnActionExecuted is better place for your code.

Body:
My action filter attribute does not redirect to the new url i have defined:

public class RunOnServerAttribute : System.Web.Http.Filters.ActionFilterAttribute
{
    public ServerType Type;

    public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext filterContext)
    {
        switch (Type)
        {
            case ServerType.CMS:
                if (!filterContext.Request.RequestUri.AbsoluteUri.StartsWith(Config.CMSUrl))
                {
                    Uri correctedUri = new Uri($"{Config.CMSUrl.TrimEnd('/')}/{filterContext.Request.RequestUri.PathAndQuery.TrimStart('/')}");
                    var response = filterContext.Request.CreateResponse(System.Net.HttpStatusCode.Moved);
                    response.Headers.Location = correctedUri;
                    return;
                    // This does not seem to work
                }

                break;
        }

        base.OnActionExecuting(filterContext);
    }
}

It just continues on with the normal request. I am debugging this by inspecting the Request.RequestUri in the executing api method


问:
How to split list to lists by condition?
I want split a list into multiple lists, based on a condition. If the difference in the series grows more than 4, then it is trigger to split the list till that item from last split item.

For example:

```<code>in = [1,2,3,9,10,11,100,200]
out = [ [1,2,3 ], [ 9,10,11 ], [100], [200]  ]
</code>```

by condition

```<code>If (next - prev) > 4
</code>```

答:
Short solution using numpy module:

```<code>import numpy as np

arr = np.array([1,2,3,9,10,11,100,200])
out = [a.tolist() for a in np.split(arr, np.where(np.diff(arr) > 4)[0]+1)]
print(out)
</code>```

The output:

```<code>[[1, 2, 3], [9, 10, 11], [100], [200]]
</code>```

np.where(np.diff(arr) > 4) - find the array indices where condition "difference between next value and previous value is greater than 4" is met

np.split(x, indices) - split the initial array by crucial indices

Body:
I want split a list into multiple lists, based on a condition. If the difference in the series grows more than 4, then it is trigger to split the list till that item from last split item.

For example:

in = [1,2,3,9,10,11,100,200]
out = [ [1,2,3 ], [ 9,10,11 ], [100], [200]  ]

by condition

If (next - prev) > 4

Body:
Short solution using numpy module:

import numpy as np

arr = np.array([1,2,3,9,10,11,100,200])
out = [a.tolist() for a in np.split(arr, np.where(np.diff(arr) > 4)[0]+1)]
print(out)

The output:

[[1, 2, 3], [9, 10, 11], [100], [200]]

np.where(np.diff(arr) > 4) - find the array indices where condition "difference between next value and previous value is greater than 4" is met

np.split(x, indices) - split the initial array by crucial indices


问:
Skype Trusted API throwing Server 500 error
I am working on a chat application and for this I am using Skype Trusted API. I followed the steps outlined here "https://msdn.microsoft.com/en-us/skype/trusted-application-api/docs/anonymousmeetingjoin". I am running into an issue with the trusted API and I need help. I am using Java 1.8, spring-boot for development.

I am able to get valid oauth token using "https://login.windows.net/{tenantId}/oauth2/token" URL and passing valid client_id, client_secret, and resource params.

Using the oauth token from step 1, I do a GET on "https://api.skypeforbusiness.com/platformService/v1/applications?endpointid=xxxx" URL to get service:application uri

Then using the oauth token from step 1 and service:application uri from step 2, I do a GET on "https://api.skypeforbusiness.com/platformService/v1/applications/{applicationId}?endpointid=xxxxxxxx" to get the service:anonApplicationTokens.

But invoking the api in step 3 is where I am having issue. It always returns  server error 500. Please find below the response:

Server returned HTTP response code: 500 for URL: https://api.skypeforbusiness.com/platformservice/v1/applications/{applicationid}?endpointId=xxxxxxxx

Please help. Also, please let me know if you need any additional details.

Thanks in advance.

答:
Here is the X-MS-ClientDiagnostics decoded  </p>

```<code>    OperationContext-ErrorCode=InternalServerError-ErrorSubCode=None-ErrorDebugProperties=errorReportId="084c7c8450d6487f8a7d3f90da1f270d"
exceptionMessage="Object reference not set to an instance of an object."
detectionStackTrace="   at PlatformService.Web.Common.UcapResourceFactory.<ToResourceAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.Common.UcapResourceFactory.ApplicationEntityTranslator.<ToResourceAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.Common.UcapResourceFactory.<ToResourceAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.ApplicationController.<Get>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Bot.ChannelConnector.BotAuthorizationFilter.<ExecuteAuthorizationFilterAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()"
-CorrelationId=3019051-HttpMethod=GET-StatusCode=500-UriPath=/platformservice/v1/applications/2826842348-UriQueryParameters=?endpointId=sip%3atest%40vulcan365.onmicrosoft.com-UserAgent=SkypeTest1-Latency=0-Timestamp=1/1/0001 8:00:00 AM-ClientId=61f97c94-e7ab-40b5-a9a2-e2549d68da27-ClientName=SkypeTest1-EndpointId=sip:test@vulcan365.onmicrosoft.com-TenantId=c37c3db4-521e-4488-9f2e-ac2dba6bf342-Machine=DM20R04FES16.infra.lync.com-FormatVersion=PlatformService 1.4-RequestedVersion=0-
</code>```

Body:
Here is the X-MS-ClientDiagnostics decoded

    OperationContext-ErrorCode=InternalServerError-ErrorSubCode=None-ErrorDebugProperties=errorReportId="084c7c8450d6487f8a7d3f90da1f270d"
exceptionMessage="Object reference not set to an instance of an object."
detectionStackTrace="   at PlatformService.Web.Common.UcapResourceFactory.<ToResourceAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.Common.UcapResourceFactory.ApplicationEntityTranslator.<ToResourceAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.Common.UcapResourceFactory.<ToResourceAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PlatformService.Web.ApplicationController.<Get>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Bot.ChannelConnector.BotAuthorizationFilter.<ExecuteAuthorizationFilterAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()"
-CorrelationId=3019051-HttpMethod=GET-StatusCode=500-UriPath=/platformservice/v1/applications/2826842348-UriQueryParameters=?endpointId=sip%3atest%40vulcan365.onmicrosoft.com-UserAgent=SkypeTest1-Latency=0-Timestamp=1/1/0001 8:00:00 AM-ClientId=61f97c94-e7ab-40b5-a9a2-e2549d68da27-ClientName=SkypeTest1-EndpointId=sip:test@vulcan365.onmicrosoft.com-TenantId=c37c3db4-521e-4488-9f2e-ac2dba6bf342-Machine=DM20R04FES16.infra.lync.com-FormatVersion=PlatformService 1.4-RequestedVersion=0-


问:
Should CodeContracts replace the regular ArgumentExceptions?
Could I start using CodeContracts instead of:

```<code>if (XXX == Y)
    throw new ArgumentException("bla bla");
</code>```

How does it work if I develop a library and my library users do not use CodeContracts?

答:
I have been using code contracts and for casual use, they address 2 code problems for me that didn't have nice solutions earlier:

checking return values checking

invariants appear to be a poorly named combined parameter check/entry point and return value/exit point assertion.

I could declare a temp variable for the return value and assert some things before return it, but it's extra friction.

checking parameters already had a solution: throw ArgumentException.

Code contracts adds one tiny thing to ArgumentException-- it makes you check arguments very early, which in my opinion is a good thing.

There is much more going on with Code Contracts, but I've just dipped my toe into and I don't have the edition that does super-comprehensive static checks.  I plan to work my way up to using Code Contracts more completely, and once I have done so-- it will be more elegant to check parameters using the same framework instead of switching back and forth between Code Contracts and if/then/throw ArgumentException

Body:
Could I start using CodeContracts instead of:

if (XXX == Y)
    throw new ArgumentException("bla bla");

How does it work if I develop a library and my library users do not use CodeContracts?


问:
CSS Grid vertical columns with infinite rows
I have a list of items of unknown length (from a CMS). I want to display them in 2 vertical columns reading down. e.g.

```
1 4
2 5
3 6

etc...
```

I am trying to achieve this with CSS grid, however, it doesn't seem possible unless you set the number of rows up front. I have tried grid-auto-flow: column as per https://gridbyexample.com/examples/example18/ but this just adds additional columns when it gets to the end.

I feel like this should be possible with grid, but I can't find a way. Anyone have any ideas?

P.S. Please don't suggest CSS text columns.

答:
You can use a flex in which there is a container and a flex item. You can limit the height of the container and then wrap the contents of flex to continue in the next column :-

```<code><body>
<div class="container">
  <p>1</p>
  <p>1</p>
  <p>1</p>
  <p>1</p>
  <p>1</p>
</div>
</body>
</code>```

CSS:

```<code>.container {
  height: 300px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
}
</code>```

Read more about flexbox

Body:
I have a list of items of unknown length (from a CMS). I want to display them in 2 vertical columns reading down. e.g.

1 4
2 5
3 6

etc...

I am trying to achieve this with CSS grid, however, it doesn't seem possible unless you set the number of rows up front. I have tried grid-auto-flow: column as per https://gridbyexample.com/examples/example18/ but this just adds additional columns when it gets to the end.

I feel like this should be possible with grid, but I can't find a way. Anyone have any ideas?

P.S. Please don't suggest CSS text columns.

Body:
You can use a flex in which there is a container and a flex item. You can limit the height of the container and then wrap the contents of flex to continue in the next column :-

<body>
<div class="container">
  <p>1</p>
  <p>1</p>
  <p>1</p>
  <p>1</p>
  <p>1</p>
</div>
</body>

CSS:

.container {
  height: 300px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
}

Read more about flexbox


问:
spring-boot-starter-jetty and Jetty modules - Maven magic
We're using spring-boot-starter-jetty in our maven pom, which means we don't have any direct dependency on jetty hence no control on its version.

This all works good, but we now need to add a dependency onone of jetty's modules, which are using the same jetty version convention.

This is all great and dandy, but because we can't use spring-boot-starter-jetty as our root pom, we're declaring jetty's version again under the module's dependency declaration, something like this:

```<code><dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jetty</artifactId>
   <version>1.4.3-RELEASE</version>
</dependency>
<dependency>
   <groupId>org.eclipse.jetty</groupId>
   <artifactId>jetty-nosql</artifactId>
   <version>9.3.14.v20161028</version>
</dependency>
</code>```

This is no fun PLUS dangerous as if we upgrade one of them, we have to remember to upgrade the latter to the same version.

I know we can add an exclude under the module's dependency but this feels like a hack plus still doesn't fully protect us from breaking changes.

Is there anyway to extract the jetty version from spring boot and reuse it for the module's dependency?

Thanks!!

答:
Maven creates the version properties for it's dependencies in the effective POM. For jetty it's jetty.version

So your dependencies will become

```<code>    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-nosql</artifactId>
        <version>${jetty.version}</version>
    </dependency>
</code>```

Here's complete POM

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
            <version>${jetty.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

It's worth pointing out that this is not required with the latest version of Spring Boot. I checked with the 1.5.4.RELEASE. Following is suficient.

```<code>    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-nosql</artifactId>
    </dependency>
</code>```

Complete POM

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

Effective POM can be generated by using following command

```<code>mvn help:effective-pom
</code>```

Or if you're using Spring Tool Suite or latest version of Eclipse then you can directly check it inside the bottom tab in the Maven POM Editor

Edit

Without spring-boot parent pom the same can be done using dependencyManagement

Following is the complete pom without spring-boot parent

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.4.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
            <version>${jetty.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

Body:
We're using spring-boot-starter-jetty in our maven pom, which means we don't have any direct dependency on jetty hence no control on its version.

This all works good, but we now need to add a dependency onone of jetty's modules, which are using the same jetty version convention.

This is all great and dandy, but because we can't use spring-boot-starter-jetty as our root pom, we're declaring jetty's version again under the module's dependency declaration, something like this:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jetty</artifactId>
   <version>1.4.3-RELEASE</version>
</dependency>
<dependency>
   <groupId>org.eclipse.jetty</groupId>
   <artifactId>jetty-nosql</artifactId>
   <version>9.3.14.v20161028</version>
</dependency>

This is no fun PLUS dangerous as if we upgrade one of them, we have to remember to upgrade the latter to the same version.

I know we can add an exclude under the module's dependency but this feels like a hack plus still doesn't fully protect us from breaking changes.

Is there anyway to extract the jetty version from spring boot and reuse it for the module's dependency?

Thanks!!

Body:
Maven creates the version properties for it's dependencies in the effective POM. For jetty it's jetty.version

So your dependencies will become

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-nosql</artifactId>
        <version>${jetty.version}</version>
    </dependency>

Here's complete POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
            <version>${jetty.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

It's worth pointing out that this is not required with the latest version of Spring Boot. I checked with the 1.5.4.RELEASE. Following is suficient.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-nosql</artifactId>
    </dependency>

Complete POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Effective POM can be generated by using following command

mvn help:effective-pom

Or if you're using Spring Tool Suite or latest version of Eclipse then you can directly check it inside the bottom tab in the Maven POM Editor

Edit

Without spring-boot parent pom the same can be done using dependencyManagement

Following is the complete pom without spring-boot parent

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestDependency</groupId>
    <artifactId>TestDependency</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>TestDependency</name>
    <description>TestDependency</description>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.4.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-nosql</artifactId>
            <version>${jetty.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>


问:
Post Increment and assigning to same variable
```<code>int b = 2;

c= b++;
System.out.Println("C :"+c+"B"+b);
</code>```

c will be 2 and b will be 3.

```<code>int b = 2;

b= b++;
System.out.Println("B:"+b);
</code>```

Here I wonder what is getting incremented. and where does that incremented value goes.

答:
I guess you just don't get what happens here:

```<code>int b = 2;

b= b++;
System.out.println("B:"+b);
</code>```

And more specifically, this line:

```<code>b = b++;
</code>```

The compiler sees that this is an assignment statement, so it tries to evaluate the expression on the right first:

```<code>b++
</code>```

Since ++ here is a post increment operator, the expression just evaluates to b, i.e. 2. Immediately after the evaluation, b is incremented to 3.

We're not done yet! This is an assignment statement remember? Now that the right side is evaluated, the expression now looks like this:

```<code>b = 2;
</code>```

Great! Now b is assigned the value of 2.

Body:
int b = 2;

c= b++;
System.out.Println("C :"+c+"B"+b);

c will be 2 and b will be 3.

int b = 2;

b= b++;
System.out.Println("B:"+b);

Here I wonder what is getting incremented. and where does that incremented value goes.

Body:
I guess you just don't get what happens here:

int b = 2;

b= b++;
System.out.println("B:"+b);

And more specifically, this line:

b = b++;

The compiler sees that this is an assignment statement, so it tries to evaluate the expression on the right first:

b++

Since ++ here is a post increment operator, the expression just evaluates to b, i.e. 2. Immediately after the evaluation, b is incremented to 3.

We're not done yet! This is an assignment statement remember? Now that the right side is evaluated, the expression now looks like this:

b = 2;

Great! Now b is assigned the value of 2.


问:
Import module in React component for publish on NPM
It's my first React component for publication in NPM. I use react-webpack-component package from Yeoman to start my project. But when I install and import my component to React app, I catch error:

```<code>Failed to compile.

Error in ./~/kladrapi-react/index.js
Module not found: [CaseSensitivePathsPlugin] `/develop/myproject/node_modules/kladrapi-react/node_modules/React/react.js` does not match the corresponding path on disk `react`.

 @ ./~/kladrapi-react/index.js 1:82-98
</code>```

I'm understand this error, but not understand how correctly import React modules to my component!

Actual version on GitHub

答:
Module not found: [CaseSensitivePathsPlugin] /develop/myproject/node_modules/kladrapi-react/node_modules/React/react.js does not match the corresponding path on disk react.

@ ./~/kladrapi-react/index.js

Body:
It's my first React component for publication in NPM. I use react-webpack-component package from Yeoman to start my project. But when I install and import my component to React app, I catch error:

Failed to compile.

Error in ./~/kladrapi-react/index.js
Module not found: [CaseSensitivePathsPlugin] `/develop/myproject/node_modules/kladrapi-react/node_modules/React/react.js` does not match the corresponding path on disk `react`.

 @ ./~/kladrapi-react/index.js 1:82-98

I'm understand this error, but not understand how correctly import React modules to my component!

Actual version on GitHub


问:
C# return json object
I have what I hope is a fairly straightforward json question.  I have a contact page where I use a jquery function to send data to a c# sendmail method.  That all works.  I am sending info back to the jquery but having trouble.

My c# is:

```<code>if (!ok)
{
    return Json(new { success = false, responseText = "FAIL" },
     JsonRequestBehavior.AllowGet);
 }
else
{
    return Json(new { success = true, responseText = "SENT" },
       JsonRequestBehavior.AllowGet);
}
</code>```

and the ajax part of the jquery is:

```<code>$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
        processData: false,
        dataType: "json",
        cache:false,
        url: "x/sendEmail",
        dataType: 'json',
        data: JSON.stringify(myData),

        //complete changed to success
        success: function (response) {
            if (response != null && response.success) {
                alert(response.success + " pass" + response.responseText);
            } else {
                alert(response.success + " fail " + response.responseText);
            }
        },
        error: function (response) {
            alert(response.success + " fail2 " + response.responseText);
        }
</code>```

I get the response.success as true or false but response.responseText is always 'undefined'.

Not sure what I am missing

I changed the C# a little but same results

```<code>public class ResponseObject
{
    public bool success { get; set; }
    public string responseText { get; set; }
}

public ActionResult sendEmail(string userName, string userEmail, string
  userPhone, string userAddress,string userSubject, string userMessage, string
  userList)
 {
       ///code to send mail - works no problem

       ResponseObject response;

        if (!ok)
        {
            //  Send "false"
            response = new ResponseObject { success = false, responseText = "FAIL" };
        }
        else
        {
            //  Send "Success"
            response = new ResponseObject { success = true, responseText = "Your message successfuly sent!" };
        }

        return Json(response, JsonRequestBehavior.AllowGet);
}
</code>```

答:
Try returning Content instead (you will need Newtonsoft.Json package)

```<code>public ActionResult sendEmail(string userName, string userEmail,string userPhone, string userAddress, string userSubject, string userMessage, string userList)
{
       ///code to send mail - works no problem
        if (!ok)
        {
            //  Send "false"
            var response = new { success = false, responseText = "FAIL" };
            return Content(Newtonsoft.Json.JsonConvert.SerializeObject(response), "application/json");
        }
        else
        {
            //  Send "Success"
            var response = new { success = true, responseText = "Your message successfuly sent!" };
            return Content(Newtonsoft.Json.JsonConvert.SerializeObject(response), "application/json");
        }
}
</code>```

Title: C# return json object

Body:
I have what I hope is a fairly straightforward json question.  I have a contact page where I use a jquery function to send data to a c# sendmail method.  That all works.  I am sending info back to the jquery but having trouble.

My c# is:

if (!ok)
{
    return Json(new { success = false, responseText = "FAIL" },
     JsonRequestBehavior.AllowGet);
 }
else
{
    return Json(new { success = true, responseText = "SENT" },
       JsonRequestBehavior.AllowGet);
}

and the ajax part of the jquery is:

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
        processData: false,
        dataType: "json",
        cache:false,
        url: "x/sendEmail",
        dataType: 'json',
        data: JSON.stringify(myData),

        //complete changed to success
        success: function (response) {
            if (response != null && response.success) {
                alert(response.success + " pass" + response.responseText);
            } else {
                alert(response.success + " fail " + response.responseText);
            }
        },
        error: function (response) {
            alert(response.success + " fail2 " + response.responseText);
        }

I get the response.success as true or false but response.responseText is always 'undefined'.

Not sure what I am missing

I changed the C# a little but same results

public class ResponseObject
{
    public bool success { get; set; }
    public string responseText { get; set; }
}

public ActionResult sendEmail(string userName, string userEmail, string
  userPhone, string userAddress,string userSubject, string userMessage, string
  userList)
 {
       ///code to send mail - works no problem

       ResponseObject response;

        if (!ok)
        {
            //  Send "false"
            response = new ResponseObject { success = false, responseText = "FAIL" };
        }
        else
        {
            //  Send "Success"
            response = new ResponseObject { success = true, responseText = "Your message successfuly sent!" };
        }

        return Json(response, JsonRequestBehavior.AllowGet);
}

Body:
Try returning Content instead (you will need Newtonsoft.Json package)

public ActionResult sendEmail(string userName, string userEmail,string userPhone, string userAddress, string userSubject, string userMessage, string userList)
{
       ///code to send mail - works no problem
        if (!ok)
        {
            //  Send "false"
            var response = new { success = false, responseText = "FAIL" };
            return Content(Newtonsoft.Json.JsonConvert.SerializeObject(response), "application/json");
        }
        else
        {
            //  Send "Success"
            var response = new { success = true, responseText = "Your message successfuly sent!" };
            return Content(Newtonsoft.Json.JsonConvert.SerializeObject(response), "application/json");
        }
}


问:
Counting the same column with different where conditions
I have a table called employees, whose schema looks like the following:

```<code>mysql> desc employees;
+------------+---------------+------+-----+---------+-------+
| Field      | Type          | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no     | int(11)       | NO   | PRI | NULL    |       |
| birth_date | date          | NO   |     | NULL    |       |
| first_name | varchar(14)   | NO   |     | NULL    |       |
| last_name  | varchar(16)   | NO   |     | NULL    |       |
| gender     | enum('M','F') | NO   |     | NULL    |       |
| hire_date  | date          | NO   |     | NULL    |       |
+------------+---------------+------+-----+---------+-------+
</code>```

I just want to query the count of emp_no for Males (where generder = 'M') and females (where generder = 'F').

I want the results like:

```<code>+--------+--------+
| Male   | FeMale |
+--------+--------+
| 300    | 120    |
+--------+--------+
</code>```

Any suggestion on how to do that in a single query?

答:
```<code>select sum(case when gender = 'm' then 1 else 0 end) male,
sum(case when gender = 'f' then 1 else 0 end) female,
from employees
</code>```

you could try something like that

Body:
I have a table called employees, whose schema looks like the following:

mysql> desc employees;
+------------+---------------+------+-----+---------+-------+
| Field      | Type          | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no     | int(11)       | NO   | PRI | NULL    |       |
| birth_date | date          | NO   |     | NULL    |       |
| first_name | varchar(14)   | NO   |     | NULL    |       |
| last_name  | varchar(16)   | NO   |     | NULL    |       |
| gender     | enum('M','F') | NO   |     | NULL    |       |
| hire_date  | date          | NO   |     | NULL    |       |
+------------+---------------+------+-----+---------+-------+

I just want to query the count of emp_no for Males (where generder = 'M') and females (where generder = 'F').

I want the results like:

+--------+--------+
| Male   | FeMale |
+--------+--------+
| 300    | 120    |
+--------+--------+

Any suggestion on how to do that in a single query?

Body:
select sum(case when gender = 'm' then 1 else 0 end) male,
sum(case when gender = 'f' then 1 else 0 end) female,
from employees

you could try something like that