问:
After execution action: Unhandled Rejection (Error): Actions may not have an undefined "type" property. Have you misspelled a constant?
Unhandled Rejection (Error): Actions may not have an undefined "type" property. Have you misspelled a constant?

trying to create an action in redux to DELETE my item. I understand that actions must have a defined type so not sure why I am getting this error

Tried looking for similar posts but none of them provide the answer that I need:

./types

export const DELETE_TASK = 'DELETE_TASK';

./actions

import {DELETE_TASK} from './types'

export const deleteTask = id => dispatch => {
  axios
    .delete(`/api/tasks/${id}`)
    .then(res =>
      dispatch({
        type: DELETE_TASK,
        payload: id
      })
    )
    .catch(err =>
      dispatch({
        type: console.log(err)
      }))
}

./reducers

case DELETE_TASK:
  return {
    ...state,
    tasks: state.dates.filter(task => task.id !== action.payload)
  };

./component

onDeleteTask = id => {
  this.props.deleteTask(id)
}

<button onClick={this.onDeleteTask.bind(this, e.id)}>delete task</button>

I have to mention after the error when I refresh the page item was delete! Action work but I don't understand why this error occurs before that

答:
This part of the code has an error

```<code>.catch(err =>
  dispatch({
    type: console.log(err)
  }))
</code>```

console.log() always returns undefined. So you're dispatching an action {type: undefined}. May be you need something like this

```<code>.catch(err => {
  console.log(err)
  dispatch({
    type: ERROR
  })
})
</code>```

given that you've defined ERROR constant.

Body:
This part of the code has an error

.catch(err =>
  dispatch({
    type: console.log(err)
  }))

console.log() always returns undefined. So you're dispatching an action {type: undefined}. May be you need something like this

.catch(err => {
  console.log(err)
  dispatch({
    type: ERROR
  })
})

given that you've defined ERROR constant.


来源: stackexchange

问:
Multiple Errors when starting server with Spring Boot
This is the log printed in console.

```<code>  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.3.RELEASE)

2017-01-09 01:23:15.384  INFO 9484 --- [           main] com.udemy.BackendninjaApplication        : Starting BackendninjaApplication on I046LA0413 with PID 9484 (C:\Users\lvelasco\workspace\backendninja\target\classes started by lvelasco in C:\Users\lvelasco\workspace\backendninja)
2017-01-09 01:23:15.387  INFO 9484 --- [           main] com.udemy.BackendninjaApplication        : No active profile set, falling back to default profiles: default
2017-01-09 01:23:15.890  INFO 9484 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4988d8b8: startup date [Mon Jan 09 01:23:15 CST 2017]; root of context hierarchy
2017-01-09 01:23:18.036  INFO 9484 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$50cfc6a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-01-09 01:23:18.466  WARN 9484 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
2017-01-09 01:23:18.477 ERROR 9484 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at com.udemy.BackendninjaApplication.main(BackendninjaApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:199) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    ... 8 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:517) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1197) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.getCustomizers(EmbeddedServletContainerCustomizerBeanPostProcessor.java:77) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1581) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    ... 16 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_112]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader.access$100(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_112]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_112]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at org.hibernate.jpa.HibernatePersistenceProvider$1.isLoadedWithoutReference(HibernatePersistenceProvider.java:171) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
    at javax.persistence.Persistence$1.isLoaded(Persistence.java:111) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
    at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:46) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:128) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:36) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1612) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1597) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:609) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:580) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:524) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:492) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:457) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:407) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:205) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:94) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.validation.DataBinder.validate(DataBinder.java:877) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.validate(PropertiesConfigurationFactory.java:367) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:287) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:256) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:347) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:303) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1581) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    ... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    ... 65 common frames omitted
</code>```

The error arrised once I create a package named entity and added some configuration in application.yml

application.yml looks like this

```<code>spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mydb
    username: root
    password:
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update
      naming:
        strategy: org.hibernate.cfg.ImprovedNamingStrategy
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect
</code>```

I've tried to rebuild the project with 'mvn clean install'
I've tried deleting all *.jars from maven dependencies and used 'Update project' from maven funcionalities.

My pom.xml looks like this:

```<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>com.udemy</groupId>
    <artifactId>backendninja</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>backendninja</name>
    <description>Este es el proyecto del curso udemy</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-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

    </dependencies>

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

</project>
</code>```

I'm new with spring mvc, maven and spring boot. Any help would be really appreciated.

** update **
By the way Im using Eclipse neon 2

答:
I also had the same error ,
solution is just upgrade to most recent version of spring-boot starter-parent of today.
thank you</p>

ContentLicense: CC BY-SA 3.0

Body:
This is the log printed in console.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.3.RELEASE)

2017-01-09 01:23:15.384  INFO 9484 --- [           main] com.udemy.BackendninjaApplication        : Starting BackendninjaApplication on I046LA0413 with PID 9484 (C:\Users\lvelasco\workspace\backendninja\target\classes started by lvelasco in C:\Users\lvelasco\workspace\backendninja)
2017-01-09 01:23:15.387  INFO 9484 --- [           main] com.udemy.BackendninjaApplication        : No active profile set, falling back to default profiles: default
2017-01-09 01:23:15.890  INFO 9484 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4988d8b8: startup date [Mon Jan 09 01:23:15 CST 2017]; root of context hierarchy
2017-01-09 01:23:18.036  INFO 9484 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$50cfc6a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-01-09 01:23:18.466  WARN 9484 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
2017-01-09 01:23:18.477 ERROR 9484 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at com.udemy.BackendninjaApplication.main(BackendninjaApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:199) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    ... 8 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:517) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1197) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.getCustomizers(EmbeddedServletContainerCustomizerBeanPostProcessor.java:77) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1581) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    ... 16 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_112]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader.access$100(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_112]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_112]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_112]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at org.hibernate.jpa.HibernatePersistenceProvider$1.isLoadedWithoutReference(HibernatePersistenceProvider.java:171) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
    at javax.persistence.Persistence$1.isLoaded(Persistence.java:111) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
    at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:46) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:128) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:36) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1612) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1597) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:609) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:580) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:524) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:492) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:457) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:407) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:205) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
    at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:94) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.validation.DataBinder.validate(DataBinder.java:877) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.validate(PropertiesConfigurationFactory.java:367) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:287) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:256) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:347) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:303) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1581) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    ... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_112]
    ... 65 common frames omitted

The error arrised once I create a package named entity and added some configuration in application.yml

application.yml looks like this

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mydb
    username: root
    password:
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update
      naming:
        strategy: org.hibernate.cfg.ImprovedNamingStrategy
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect

I've tried to rebuild the project with 'mvn clean install'
I've tried deleting all *.jars from maven dependencies and used 'Update project' from maven funcionalities.

My pom.xml looks like this:

<?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>com.udemy</groupId>
    <artifactId>backendninja</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>backendninja</name>
    <description>Este es el proyecto del curso udemy</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
        <relativePath/>
    </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-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

    </dependencies>

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

</project>

I'm new with spring mvc, maven and spring boot. Any help would be really appreciated.

** update **
By the way Im using Eclipse neon 2

ContentLicense: CC BY-SA 4.0


问:
Laravel returns a "unexpected $this" error when Model defines an eloquent relationship
I have a Post table which refers to a User table. A user can have many posts, and a Post belongs to a User. I created all the tables, with the Post table having a user_id foreign key. I also created a Post Model like this :

```<code><?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    public function user(){
        //dd($this->belongsTo("App\User"));
        return $this->belongsTo("App\User");
    }

}
</code>```

The dd() dumps this :

```<code>Illuminate\Database\Eloquent\Relations\BelongsTo {#282 ▼
  #child: App\Post {#286 ▶}
  #foreignKey: "user_id"
  #ownerKey: "id"
  #relationName: "user"
  #query: Illuminate\Database\Eloquent\Builder {#262 ▶}
  #parent: App\Post {#286 ▶}
  #related: App\User {#274 ▶}
  #withDefault: null
}
</code>```

However I get a Symfony\Component\Debug\Exception\FatalThrowableError syntax error, unexpected '$this' (T_VARIABLE)

I don't understand why $this is not refering to the class itself and is not understood. Any clue ?
Thanks.

答: Actually @ChristophKluge was right, turns out there probably was a magic character dûe to a copy paste. VSStudioCode didn't manage it well as it displayed nothing... Thanks guys. </p>

Body:
I have a Post table which refers to a User table. A user can have many posts, and a Post belongs to a User. I created all the tables, with the Post table having a user_id foreign key. I also created a Post Model like this :

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    public function user(){
        //dd($this->belongsTo("App\User"));
        return $this->belongsTo("App\User");
    }

}

The dd() dumps this :

Illuminate\Database\Eloquent\Relations\BelongsTo {#282 ▼
  #child: App\Post {#286 ▶}
  #foreignKey: "user_id"
  #ownerKey: "id"
  #relationName: "user"
  #query: Illuminate\Database\Eloquent\Builder {#262 ▶}
  #parent: App\Post {#286 ▶}
  #related: App\User {#274 ▶}
  #withDefault: null
}

However I get a Symfony\Component\Debug\Exception\FatalThrowableError syntax error, unexpected '$this' (T_VARIABLE)

I don't understand why $this is not refering to the class itself and is not understood. Any clue ?
Thanks.


问:
Change profile picture in django
I'm trying to make a edit profile module , but it needs to change profile picture too.. I already try some code , but the picture isnt change when I press the submit button

Here's the views.py for update_profile

```<code>def update_profile(request):
    if request.method == 'POST':
        user_form = UserInfoForm(request.POST, instance=request.user )
        profile_form = UserProfileInfoForm(request.POST, instance=request.user.profile)
        if user_form.is_valid() and profile_form.is_valid():
            user = user_form.save()
            user.save()
            profile = profile_form.save(commit=False)
            profile.user = user
            if 'profile_pic' in request.FILES:
                profile.profile_pic = request.FILES['profile_pic']
            profile.save()
            return redirect('/profile/')
        else:
            messages.error(request, ('Please correct the error below.'))
    else:
        user_form = UserInfoForm(instance=request.user)
        profile_form = UserProfileInfoForm(instance=request.user.profile)
    return render(request, 'profile.html', {
        'user_form': user_form,
        'profile_form': profile_form
    })
</code>```

here's the form

```<code><form role="form" class="form-horizontal" method="post">

                          {% load staticfiles %}
                          {% block body_block %}

                                {% if registered %}
                                  <h1>Update Profile Success!</h1>
                                {% else %}
                                  <form class="cmxform form-horizontal style-form" id="commentForm" enctype="multipart/form-data" method="POST" action="">
                                    {% csrf_token %}
                                    {{ user_form.as_p }}
                                    {{ profile_form.as_p }}

                                    <input type="submit" name="" value="Update">
                                  </form>

                                {% endif %}

                          {% endblock %}

                        </form>
</code>```

urls.py (already add +static[]) from someone suggestion and still not working

```<code>app_name = 'polls'
urlpatterns = [
    path('profile/', views.update_profile, name='profile'),
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
</code>```

Hope someone can solve the problem, thank you.

答:
You are not passing the file to your form, so add request.FILES as the second parameter to form containing the picture in your view, e.g.

```<code>profile_form = UserProfileInfoForm(request.POST, request.FILES, instance=request.user.profile
</code>```

Title: Change profile picture in django

Body:
I'm trying to make a edit profile module , but it needs to change profile picture too.. I already try some code , but the picture isnt change when I press the submit button

Here's the views.py for update_profile

def update_profile(request):
    if request.method == 'POST':
        user_form = UserInfoForm(request.POST, instance=request.user )
        profile_form = UserProfileInfoForm(request.POST, instance=request.user.profile)
        if user_form.is_valid() and profile_form.is_valid():
            user = user_form.save()
            user.save()
            profile = profile_form.save(commit=False)
            profile.user = user
            if 'profile_pic' in request.FILES:
                profile.profile_pic = request.FILES['profile_pic']
            profile.save()
            return redirect('/profile/')
        else:
            messages.error(request, ('Please correct the error below.'))
    else:
        user_form = UserInfoForm(instance=request.user)
        profile_form = UserProfileInfoForm(instance=request.user.profile)
    return render(request, 'profile.html', {
        'user_form': user_form,
        'profile_form': profile_form
    })

here's the form

<form role="form" class="form-horizontal" method="post">

                          {% load staticfiles %}
                          {% block body_block %}

                                {% if registered %}

Update Profile Success!

                                {% else %}
                                  <form class="cmxform form-horizontal style-form" id="commentForm" enctype="multipart/form-data" method="POST" action="">
                                    {% csrf_token %}
                                    {{ user_form.as_p }}
                                    {{ profile_form.as_p }}

                                    <input type="submit" name="" value="Update">
                                  </form>

                                {% endif %}

                          {% endblock %}

                        </form>

urls.py (already add +static[]) from someone suggestion and still not working

app_name = 'polls'
urlpatterns = [
    path('profile/', views.update_profile, name='profile'),
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Hope someone can solve the problem, thank you.

Body:
You are not passing the file to your form, so add request.FILES as the second parameter to form containing the picture in your view, e.g.

profile_form = UserProfileInfoForm(request.POST, request.FILES, instance=request.user.profile


问:
Set range equal to multiple named ranges with line break
I am setting a range variable equal to a list of ranges. The list is so long that I would like to use a line break for easier management. However, I am having a tough time getting the syntax. I've tried many combinations.

The code in one line works and looks like this (with a lot more named ranges):

```<code>Dim xNamedRangeList As Range
Set xNamedRangeList = Range("NamedRange1, NamedRange2")
</code>```

My best attempt so far is this.

```<code>Set xNamedRangeList = " Range(""" & _
"NamedRange1," & _
"NamedRange2" &_
""")"
</code>```

Debug.print looks like this: Ranged("NamedRange1, NamedRange2")

While this works in debug.print, it sure doesn't work when I set xNamedRangeList equal to it. I think I've turned the formula into a string, but not sure how to make it work in the formula.

答:
```<code>Set xNamedRangeList = Range("NamedRange1," & _
                            "NamedRange2," & _
                            "NamedRange3")
</code>```

Body:
I am setting a range variable equal to a list of ranges. The list is so long that I would like to use a line break for easier management. However, I am having a tough time getting the syntax. I've tried many combinations.

The code in one line works and looks like this (with a lot more named ranges):

Dim xNamedRangeList As Range
Set xNamedRangeList = Range("NamedRange1, NamedRange2")

My best attempt so far is this.

Set xNamedRangeList = " Range(""" & _
"NamedRange1," & _
"NamedRange2" &_
""")"

Debug.print looks like this: Ranged("NamedRange1, NamedRange2")

While this works in debug.print, it sure doesn't work when I set xNamedRangeList equal to it. I think I've turned the formula into a string, but not sure how to make it work in the formula.


问:
DatePicker dialog is not showing on single tap
Expectation:

When user will tap on MaterialTextView component, DatePickerDialog should open.

Whats happening:

User needs to tap twice on MaterialTextView component for opening DatePickerDialog.

MainActivity

```<code>protected void onCreate(Bundle SavedInstanceState){
MaterialTextView issueDate = findViewById(R.id.edIssueDate);
 issueDate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Calendar c = Calendar.getInstance();
            int year = c.get(Calendar.YEAR);
            int month = c.get(Calendar.MONTH);
            int day = c.get(Calendar.DAY_OF_MONTH);

            hideKeyboard(AddNewCoupon.this);
            DatePickerDialog datePickerDialog = new DatePickerDialog(AddNewCoupon.this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    issueDate.setText(String.valueOf(dayOfMonth)+"/"+String.valueOf(month)+"/"+String.valueOf(year));
                    //newCustomer.hideKeyboard(AddNewCoupon.this);
                }
            }, year, month, day);
            datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
            datePickerDialog.show();
        }
    });
}
</code>```

hideKeyboard() method:

```<code>public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    View view = activity.getCurrentFocus();
    if (view == null) {
        view = new View(activity);
    }

    if (imm != null)
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
</code>```

Layout:

```<code><com.google.android.material.textview.MaterialTextView
                        android:id="@+id/edIssueDate"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4dp"
                        android:ems="10"
                        android:focusable="auto"
                        android:focusableInTouchMode="true"
                        android:hint="@string/txtVIssueingDtHint"
                        android:nextFocusDown="@id/edExpDate"
                        android:onClick="showDatePickerDialogForIssue"
                        android:paddingLeft="4dp"
                        android:textColor="@color/design_default_color_on_secondary"
                        android:textSize="18sp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/textView2" />
</code>```

Dependencies:

```<code>dependencies {
...

implementation 'com.google.android.material:material:1.2.0-alpha04'

...
}
</code>```

Code runs perfectly as DatePickerDialog opens but the problem is user needs to tap twice for opeining it. Where I've made mistake? How can I fix the code?

答:
Change focusable and focusableInTouchMode value to false, It will do the trick

```<code> android:focusable="false"
 android:focusableInTouchMode="false"
</code>```

Hope this will help!!

Body:
Expectation:

When user will tap on MaterialTextView component, DatePickerDialog should open.

Whats happening:

User needs to tap twice on MaterialTextView component for opening DatePickerDialog.

MainActivity

protected void onCreate(Bundle SavedInstanceState){
MaterialTextView issueDate = findViewById(R.id.edIssueDate);
 issueDate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Calendar c = Calendar.getInstance();
            int year = c.get(Calendar.YEAR);
            int month = c.get(Calendar.MONTH);
            int day = c.get(Calendar.DAY_OF_MONTH);

            hideKeyboard(AddNewCoupon.this);
            DatePickerDialog datePickerDialog = new DatePickerDialog(AddNewCoupon.this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    issueDate.setText(String.valueOf(dayOfMonth)+"/"+String.valueOf(month)+"/"+String.valueOf(year));
                    //newCustomer.hideKeyboard(AddNewCoupon.this);
                }
            }, year, month, day);
            datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
            datePickerDialog.show();
        }
    });
}

hideKeyboard() method:

public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    View view = activity.getCurrentFocus();
    if (view == null) {
        view = new View(activity);
    }

    if (imm != null)
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

Layout:

<com.google.android.material.textview.MaterialTextView
                        android:id="@+id/edIssueDate"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4dp"
                        android:ems="10"
                        android:focusable="auto"
                        android:focusableInTouchMode="true"
                        android:hint="@string/txtVIssueingDtHint"
                        android:nextFocusDown="@id/edExpDate"
                        android:onClick="showDatePickerDialogForIssue"
                        android:paddingLeft="4dp"
                        android:textColor="@color/design_default_color_on_secondary"
                        android:textSize="18sp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/textView2" />

Dependencies:

dependencies {
...

implementation 'com.google.android.material:material:1.2.0-alpha04'

...
}

Code runs perfectly as DatePickerDialog opens but the problem is user needs to tap twice for opeining it. Where I've made mistake? How can I fix the code?

Body:
Change focusable and focusableInTouchMode value to false, It will do the trick

 android:focusable="false"
 android:focusableInTouchMode="false"

Hope this will help!!


问:
Getting user input as a argument for a script
I am trying to make a bash script that gives the user options 1-5,with 5 being to exit. For option 2 I want the to be able to pass the file name as a argument for the file_size script but even when I catch the user input it still says the error message please enter a single file name as an argument. I am not sure why is doesn't pass it as a argument, Any help would be appreciated.</p>

```<code>    #!/bin/bash

# usage: ./menu_script

exitvar=false

while [ $exitvar = "false" ]  # keep looping until exit equal true
  do

echo -n "Enter a number 1 through 5, 5 to exit"
read number

case $number in
1) echo "Move empty files"
/home/student/move_empty;;

2) echo "Check file size"
echo -n "Enter a file name to check: "
read sourcefile

/home/student/file_size;;

3) echo "Option3";;

4) echo "File check rwx"
echo -n "Enter a file name to check: "
read  sourcefile

if [ -e $sourcefile ]  # does the source file exist?
 then
   echo $sourcefile "exists!"
  fi

# find out if file has write permission or not
[ -w $sourcefile ] && W="Write = yes" || W="Write = No"

# find out if file has excute permission or not
[ -x $sourcefile ] && X="Execute = yes" || X="Execute = No"

# find out if file has read permission or not
[ -r $sourcefile ] && R="Read = yes" || R="Read = No"

echo "$sourcefile permissions"
echo "$W"
echo "$R"
echo "$X"

;;

5) echo "exit"
   exitvar="true"
   ;;
 *) echo "Invalid number try again"
   ;;
 esac
done
</code>```

答:
Or run subscripts with source or . this way subscripts will gain access to vars in main script

```<code>source /home/student/file_size
.      /home/student/file_size
</code>```

And use -p option for read to minimize echoes

```<code>read -r -p "Enter a file name to check: " sourcefile
</code>```

Body:
I am trying to make a bash script that gives the user options 1-5,with 5 being to exit. For option 2 I want the to be able to pass the file name as a argument for the file_size script but even when I catch the user input it still says the error message please enter a single file name as an argument. I am not sure why is doesn't pass it as a argument, Any help would be appreciated.

    #!/bin/bash

# usage: ./menu_script

exitvar=false

while [ $exitvar = "false" ]  # keep looping until exit equal true
  do

echo -n "Enter a number 1 through 5, 5 to exit"
read number

case $number in
1) echo "Move empty files"
/home/student/move_empty;;

2) echo "Check file size"
echo -n "Enter a file name to check: "
read sourcefile

/home/student/file_size;;

3) echo "Option3";;

4) echo "File check rwx"
echo -n "Enter a file name to check: "
read  sourcefile

if [ -e $sourcefile ]  # does the source file exist?
 then
   echo $sourcefile "exists!"
  fi

# find out if file has write permission or not
[ -w $sourcefile ] && W="Write = yes" || W="Write = No"

# find out if file has excute permission or not
[ -x $sourcefile ] && X="Execute = yes" || X="Execute = No"

# find out if file has read permission or not
[ -r $sourcefile ] && R="Read = yes" || R="Read = No"

echo "$sourcefile permissions"
echo "$W"
echo "$R"
echo "$X"

;;

5) echo "exit"
   exitvar="true"
   ;;
 *) echo "Invalid number try again"
   ;;
 esac
done

Body:
Or run subscripts with source or . this way subscripts will gain access to vars in main script

source /home/student/file_size
.      /home/student/file_size

And use -p option for read to minimize echoes

read -r -p "Enter a file name to check: " sourcefile


问:
Form.Load event not firing, form showing
I fear that there is something obviously wrong with my code, but I have come across a situation where the Form.Load event is not firing when I create and show my form.

The form is not subclassed (as I've seen some problems with that in some searches), and I am not getting any errors thrown when I step through the code in the debugger.

I have a break point set on the IDE-created form load function (which does have the Handles MyBase.Load signature suffix) but the breakpoint is never reached and the form does display and work.

The form is passed three arguments in the constructor but the IntializeComponent() function is called before anything else is done.

Code:

```<code>Public Sub New(ByVal argA As Object, ByVal argB As Object, ByVal mode As FormMode)

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Other code here,
    ' No errors generated
    '

End Sub
</code>```

The form load function is as follows, (but this is never actually executed as the event is not fired).

Code:

```<code>Private Sub frmInstrumentEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not argA Is Nothing Then ' argA set in constructor
          ' Operations using argA
    End If
End Sub
</code>```

I might add I am using some databinding with some controls and the argA object, but if this was producing an error I thought I would have seen this (I have CLR Execpetions settings set to Thown in the debugger > exceptions window)

Any ideas why this might be occurring?

答: Is your windows form inheriting from a base page?  If so, the base page probably also has a Form Load event handler.  In that base page Form Load event handler you will probably find an exception that is being thrown.  So it is exiting the base page form load event handler and not firing the form load event handler in your inherited windows form.</p>

Body:
I fear that there is something obviously wrong with my code, but I have come across a situation where the Form.Load event is not firing when I create and show my form.

The form is not subclassed (as I've seen some problems with that in some searches), and I am not getting any errors thrown when I step through the code in the debugger.

I have a break point set on the IDE-created form load function (which does have the Handles MyBase.Load signature suffix) but the breakpoint is never reached and the form does display and work.

The form is passed three arguments in the constructor but the IntializeComponent() function is called before anything else is done.

Code:

Public Sub New(ByVal argA As Object, ByVal argB As Object, ByVal mode As FormMode)

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Other code here,
    ' No errors generated
    '

End Sub

The form load function is as follows, (but this is never actually executed as the event is not fired).

Code:

Private Sub frmInstrumentEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not argA Is Nothing Then ' argA set in constructor
          ' Operations using argA
    End If
End Sub

I might add I am using some databinding with some controls and the argA object, but if this was producing an error I thought I would have seen this (I have CLR Execpetions settings set to Thown in the debugger > exceptions window)

Any ideas why this might be occurring?


问:
How do I prevent my script from being run every time a Docker container is brought up?
I would to run a script (populate my MySql Docker container) only when my docker containers are built.  I'm running the following docker-compose.yml file, which contains a Django container.

```<code>version: '3'

services:
  mysql:
    restart: always
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: 'maps_data'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'chicommons'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'password'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'password'
    ports:
      - "3406:3406"
    volumes:
      - my-db:/var/lib/mysql

  web:
    restart: always
    build: ./web
    ports:           # to access the container from outside
      - "8000:8000"
    env_file: .env
    environment:
      DEBUG: 'true'
    command: /usr/local/bin/gunicorn maps.wsgi:application -w 2 -b :8000
    depends_on:
      - mysql

  apache:
    restart: always
    build: ./apache/
    ports:
      - "80:80"
    #volumes:
    #  - web-static:/www/static
    links:
      - web:web

volumes:
  my-db:
</code>```

I have this web/Dockerfile

```<code>FROM python:3.7-slim

RUN apt-get update && apt-get install

RUN apt-get install -y libmariadb-dev-compat libmariadb-dev
RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc \
    && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip
RUN mkdir -p /app/

WORKDIR /app/

COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt

COPY entrypoint.sh /app/
COPY . /app/
RUN ["chmod", "+x", "/app/entrypoint.sh"]

ENTRYPOINT ["/app/entrypoint.sh"]
</code>```

and these are the contents of my entrypoint.sh file

```<code>#!/bin/bash
set -e

python manage.py migrate maps
python manage.py loaddata maps/fixtures/country_data.yaml
python manage.py loaddata maps/fixtures/seed_data.yaml

exec "$@"
</code>```

The issue is, when I repeatedly run "docker-compose up," the entrypoint.sh script is getting run with its commands.  I would prefer the commands only get run when the docker container is first built but they seem to always get run when the container is restored.  Is there any way to adjust what I have to achieve this?

答:
Instead of using the entrypoint.sh file, why not just run the commands in the web/Dockerfile?

```<code>RUN python manage.py migrate maps
RUN python manage.py loaddata maps/fixtures/country_data.yaml
RUN python manage.py loaddata maps/fixtures/seed_data.yaml
</code>```

That way these changes will be baked into the image and, when you start the image, these changes will already have been executed.

Body:
I would to run a script (populate my MySql Docker container) only when my docker containers are built.  I'm running the following docker-compose.yml file, which contains a Django container.

version: '3'

services:
  mysql:
    restart: always
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: 'maps_data'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'chicommons'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'password'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'password'
    ports:
      - "3406:3406"
    volumes:
      - my-db:/var/lib/mysql

  web:
    restart: always
    build: ./web
    ports:           # to access the container from outside
      - "8000:8000"
    env_file: .env
    environment:
      DEBUG: 'true'
    command: /usr/local/bin/gunicorn maps.wsgi:application -w 2 -b :8000
    depends_on:
      - mysql

  apache:
    restart: always
    build: ./apache/
    ports:
      - "80:80"
    #volumes:
    #  - web-static:/www/static
    links:
      - web:web

volumes:
  my-db:

I have this web/Dockerfile

FROM python:3.7-slim

RUN apt-get update && apt-get install

RUN apt-get install -y libmariadb-dev-compat libmariadb-dev
RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc \
    && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip
RUN mkdir -p /app/

WORKDIR /app/

COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt

COPY entrypoint.sh /app/
COPY . /app/
RUN ["chmod", "+x", "/app/entrypoint.sh"]

ENTRYPOINT ["/app/entrypoint.sh"]

and these are the contents of my entrypoint.sh file

#!/bin/bash
set -e

python manage.py migrate maps
python manage.py loaddata maps/fixtures/country_data.yaml
python manage.py loaddata maps/fixtures/seed_data.yaml

exec "$@"

The issue is, when I repeatedly run "docker-compose up," the entrypoint.sh script is getting run with its commands.  I would prefer the commands only get run when the docker container is first built but they seem to always get run when the container is restored.  Is there any way to adjust what I have to achieve this?

Body:
Instead of using the entrypoint.sh file, why not just run the commands in the web/Dockerfile?

RUN python manage.py migrate maps
RUN python manage.py loaddata maps/fixtures/country_data.yaml
RUN python manage.py loaddata maps/fixtures/seed_data.yaml

That way these changes will be baked into the image and, when you start the image, these changes will already have been executed.


问:
if(btnaAddStudent_Click) pop-out notif will be shown and redirect to another page
After tapping the add student button... I want to show a pop-out notification that it successfully add a student and redirects to Attendance.aspx. How would I do that?

MY Code

```<code>~~~if(btnaAddStudent_Click)
    {
        Response.Write("<script>alert('Adding Student Successful')</script>");
        Response.Redirect("~/Attendance.aspx");
    }~~~
</code>```

答:
You can use this approach:

First create Javascript function like:

```<code><script>
    function showMessageAndRedirectToAttandancePage() {
        alert("Adding Student Successful");
        window.location.href = "/Attendance.aspx";
    }
</script>
</code>```

Then you should call this function from code behind:

```<code>if(btnaAddStudent_Click)
{
     Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "showMessageAndRedirectToAttandancePage()", true);
}
</code>```

Body:
After tapping the add student button... I want to show a pop-out notification that it successfully add a student and redirects to Attendance.aspx. How would I do that?

MY Code

~~~if(btnaAddStudent_Click)
    {
        Response.Write("");
        Response.Redirect("~/Attendance.aspx");
    }~~~

Body:
You can use this approach:

First create Javascript function like:

<script>
    function showMessageAndRedirectToAttandancePage() {
        alert("Adding Student Successful");
        window.location.href = "/Attendance.aspx";
    }
</script>

Then you should call this function from code behind:

if(btnaAddStudent_Click)
{
     Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "showMessageAndRedirectToAttandancePage()", true);
}


问:
Angular: Getting TypeError: Object(...) is not a function
I have an angular project as a private repository in my GitHub and after clone it to my device and run npm install to generate node_module from my package.json I get this error in my inspect window:

this is my package.json file:

```<code>{
  "name": "my-project",
  "version": "4.3.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --port 4200",
    "hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.1.3",
    "@angular/cdk": "^7.1.3",
    "@angular/common": "^7.1.3",
    "@angular/compiler": "^7.1.3",
    "@angular/core": "^7.1.3",
    "@angular/flex-layout": "^8.0.0-beta.26",
    "@angular/forms": "^7.1.3",
    "@angular/http": "^7.1.3",
    "@angular/platform-browser": "^7.1.3",
    "@angular/platform-browser-dynamic": "^7.1.3",
    "@angular/router": "^7.1.3",
...
      },
....
    }
</code>```

答:
You Are using Every dependancy of 7.1.3 But your @angular/flex-layout id 8.0
So You need to downgrade that version or else upgrade other versions to 8

npm i @angular/flex-layout@7.0.0-beta.24
Hope it will help you!

Body:
I have an angular project as a private repository in my GitHub and after clone it to my device and run npm install to generate node_module from my package.json I get this error in my inspect window:

this is my package.json file:

{
  "name": "my-project",
  "version": "4.3.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --port 4200",
    "hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.1.3",
    "@angular/cdk": "^7.1.3",
    "@angular/common": "^7.1.3",
    "@angular/compiler": "^7.1.3",
    "@angular/core": "^7.1.3",
    "@angular/flex-layout": "^8.0.0-beta.26",
    "@angular/forms": "^7.1.3",
    "@angular/http": "^7.1.3",
    "@angular/platform-browser": "^7.1.3",
    "@angular/platform-browser-dynamic": "^7.1.3",
    "@angular/router": "^7.1.3",
...
      },
....
    }


问:
Board Column not showing on Tasks and Bugs on Query in Azure DevOps
what do i need to configure to show on what board column my tasks and bug is located in Azure DevOps. Currently it only displays on Epic,Feature and User Stories only.

答:
It is by design that Tasks and Bugs are not shown with Epics, Features, and Stories in Boards, for Tasks is not of backlog level and it is managed within Stories as child item. For details please check this document.

Hovever you can easily create new tasks, tests and bugs from the a story's board. Please check the document Add a task or set of tasks on Boards. You can check the document for more information about add child items from Backlogs

The operation that is supported by azure devops currently is that you can setup Bugs shown with Epics, Features, and Stories. Please check documents Set your team's preferences for tracking bugs

You can also choose to hide or show one or more backlog level(Epics, Features, Stories) for Backlog navigation. For detailed information please check document Select backlog navigation levels for your team.

If you want to suggest Microsoft to support showing tasks and bugs with Stories and Epics. You can submit a feature(click suggest a feature and choose azure devops) request here.


问:
Access from design wrapper to variables of own IP block in Vivado (verilog)
I have a question. I created a block diagram in Vivado2018.2. One of the blocks is an own created IP block. I want access to a variable of this own IP block in my design wrapper to test something. My design wrapper looks like:

```<code>`timescale 1 ps / 1 ps

module design_1_wrapper
   ();

design_1 design_1_i
   ();

endmodule
</code>```

I would like to add LD0 - LD7 in the outputs, that's not an issue.
But something like

```<code>assign LD0 = design_1.
</code>```

or

```<code>assign LD0 = design_1_i.
</code>```

followed by name of my block and internal modules in a pointwise way dos=esn't work because he twice mentions that he doesn't recognize design_1 or design_1_i. Has anyone an idea what I am doing wrong?

Kind regards and thanks in advance.

答:
Hey in the block diagram of vivado make the desired ports as output ports, such that ur new design wrapper will look like</p>

```<code>    `timescale 1 ps / 1 ps

module design_1_wrapper
   ();

design_1 design_1_i
 (......
  ,.LED       (LED(7:0))
);

endmodule
</code>```

Body:
I have a question. I created a block diagram in Vivado2018.2. One of the blocks is an own created IP block. I want access to a variable of this own IP block in my design wrapper to test something. My design wrapper looks like:

`timescale 1 ps / 1 ps

module design_1_wrapper
   ();

design_1 design_1_i
   ();

endmodule

I would like to add LD0 - LD7 in the outputs, that's not an issue.
But something like

assign LD0 = design_1.

or

assign LD0 = design_1_i.

followed by name of my block and internal modules in a pointwise way dos=esn't work because he twice mentions that he doesn't recognize design_1 or design_1_i. Has anyone an idea what I am doing wrong?

Kind regards and thanks in advance.

Body:
Hey in the block diagram of vivado make the desired ports as output ports, such that ur new design wrapper will look like

    `timescale 1 ps / 1 ps

module design_1_wrapper
   ();

design_1 design_1_i
 (......
  ,.LED       (LED(7:0))
);

endmodule


问:
Laravel | How to display attributes assigned to products in category view
I have problem with relationship query. I have in my show.blade.php (category):

```<code>@foreach( $attributes as $attribute)
 {{ $attribute->title }}
@endforeach
</code>```

and in CategoryController function show:

```<code>$attributes = Attribute::where('visible',1)
        ->orderBy('order', 'asc')
        ->with('products')
        ->get();
</code>```

I need to display product attributes for specific categories. Solution displaying all attributes from the database. I have 3 categories, each of these categories has products that have their own attributes. Not all attributes are in all categories.

My model relationship is: Category 1:n Product N : (pivot product_attribute) : N Attribute

Category id is passed from the view. I also have access to a specific category. But how to display the attributes of products in this category. Do you have any idea?

答:
Assuming you have relationships defined properly in Attribute and Product models, You can use below query to get Attributes of specific category

```<code>$attributes = Attribute::with(['product.category'])->whereHas('product.category', function($q) use ($categoryId) {
  $q->where('id', $categoryId);
})->get();
</code>```

Here product is relation name defined in Attribute model and category is relation name defined in Product model. id is primary key field in category table.

Body:
I have problem with relationship query. I have in my show.blade.php (category):

@foreach( $attributes as $attribute)
 {{ $attribute->title }}
@endforeach

and in CategoryController function show:

$attributes = Attribute::where('visible',1)
        ->orderBy('order', 'asc')
        ->with('products')
        ->get();

I need to display product attributes for specific categories. Solution displaying all attributes from the database. I have 3 categories, each of these categories has products that have their own attributes. Not all attributes are in all categories.

My model relationship is: Category 1:n Product N : (pivot product_attribute) : N Attribute

Category id is passed from the view. I also have access to a specific category. But how to display the attributes of products in this category. Do you have any idea?

Body:
Assuming you have relationships defined properly in Attribute and Product models, You can use below query to get Attributes of specific category

$attributes = Attribute::with(['product.category'])->whereHas('product.category', function($q) use ($categoryId) {
  $q->where('id', $categoryId);
})->get();

Here product is relation name defined in Attribute model and category is relation name defined in Product model. id is primary key field in category table.


问:
Finding the current volume level of the speaker output in Windows
EDITED: I'm trying to write a sort of audio visualizer and I need to get the current volume of the sound being sent to the speakers. I need the actual volume of the sound, not just the master volume of the device. I've been trying to do it using this but I'm unsure how to implement it. Having called the IAudioCaptureClient::GetBuffer() method, I don't know how to use the resulting data packet to find what I need. The audio is 2 channel, 32 bits per sample. Any help would be greatly appreciated. </p>

答:
Starting with Windows 7, the existing APIs have been improved and new
  APIs have been added to support new scenarios. The stream and session
  management APIs have been improved so that the application can now
  enumerate and get extended control over the audio session. By using
  the new APIs, the application can implement a custom stream
  attenuation experience. New device-related APIs provide access to the
  driver properties of the endpoint devices.

Refer: Core Audio APIs

Here is a simple demo for reference:

```<code>#include <Windows.h>
#include <stdio.h>
#include <mmeapi.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <audioclient.h>

#pragma comment(lib,"Winmm.lib")

bool GetVolumeLevel()
{
    HRESULT hr;
    IMMDeviceEnumerator* pDeviceEnumerator = 0;
    IMMDevice* pDevice = 0;
    IAudioEndpointVolume* pAudioEndpointVolume = 0;

    try {
        hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pDeviceEnumerator);
        if (FAILED(hr)) throw "CoCreateInstance";
        hr = pDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDevice);
        if (FAILED(hr)) throw "GetDefaultAudioEndpoint";
        hr = pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pAudioEndpointVolume);
        if (FAILED(hr)) throw "pDevice->Active";

        float fVolume;

        hr = pAudioEndpointVolume->GetMasterVolumeLevelScalar(&fVolume);
        printf("%lf", fVolume);
        if (FAILED(hr)) throw "SetMasterVolumeLevelScalar";

        pAudioEndpointVolume->Release();
        pDevice->Release();
        pDeviceEnumerator->Release();
            return true;
    }
    catch (...) {
        if (pAudioEndpointVolume) pAudioEndpointVolume->Release();
        if (pDevice) pDevice->Release();
        if (pDeviceEnumerator) pDeviceEnumerator->Release();
        throw;
    }
    return false;
}

int main()
{
    CoInitialize(0);
    try {
        GetVolumeLevel();

    }
    catch (...) {
        //err handle..
    }
    CoUninitialize();

    getchar();
    return 0;
}
</code>```

It will return to the volume level of the current speaker.

You can focus on this api: IAudioEndpointVolume::GetMasterVolumeLevelScal

The GetMasterVolumeLevelScalar method gets the master volume level of
  the audio stream that enters or leaves the audio endpoint device. The
  volume level is expressed as a normalized, audio-tapered value in the
  range from 0.0 to 1.0.

Body:
Starting with Windows 7, the existing APIs have been improved and new
  APIs have been added to support new scenarios. The stream and session
  management APIs have been improved so that the application can now
  enumerate and get extended control over the audio session. By using
  the new APIs, the application can implement a custom stream
  attenuation experience. New device-related APIs provide access to the
  driver properties of the endpoint devices.

Refer: Core Audio APIs

Here is a simple demo for reference:

#include <Windows.h>
#include <stdio.h>
#include <mmeapi.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <audioclient.h>

#pragma comment(lib,"Winmm.lib")

bool GetVolumeLevel()
{
    HRESULT hr;
    IMMDeviceEnumerator* pDeviceEnumerator = 0;
    IMMDevice* pDevice = 0;
    IAudioEndpointVolume* pAudioEndpointVolume = 0;

    try {
        hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pDeviceEnumerator);
        if (FAILED(hr)) throw "CoCreateInstance";
        hr = pDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDevice);
        if (FAILED(hr)) throw "GetDefaultAudioEndpoint";
        hr = pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pAudioEndpointVolume);
        if (FAILED(hr)) throw "pDevice->Active";

        float fVolume;

        hr = pAudioEndpointVolume->GetMasterVolumeLevelScalar(&fVolume);
        printf("%lf", fVolume);
        if (FAILED(hr)) throw "SetMasterVolumeLevelScalar";

        pAudioEndpointVolume->Release();
        pDevice->Release();
        pDeviceEnumerator->Release();
            return true;
    }
    catch (...) {
        if (pAudioEndpointVolume) pAudioEndpointVolume->Release();
        if (pDevice) pDevice->Release();
        if (pDeviceEnumerator) pDeviceEnumerator->Release();
        throw;
    }
    return false;
}

int main()
{
    CoInitialize(0);
    try {
        GetVolumeLevel();

    }
    catch (...) {
        //err handle..
    }
    CoUninitialize();

    getchar();
    return 0;
}

It will return to the volume level of the current speaker.

You can focus on this api: IAudioEndpointVolume::GetMasterVolumeLevelScal

The GetMasterVolumeLevelScalar method gets the master volume level of
  the audio stream that enters or leaves the audio endpoint device. The
  volume level is expressed as a normalized, audio-tapered value in the
  range from 0.0 to 1.0.


问:
Django -- treating many-to-many object set as one entity while filtering
Say I have three models -- Person, Food, Flavor.

Person and Flavor share a many-to-many relationship (a person can like many flavors).

Food and Flavor share a many-to-many relationship (a food can have many flavors).

For any given person, I would like to return all foods that have a set of flavors that is a subset of the person's flavors.

For example,

personA.flavor.all() --> ['spicy', 'sweet', 'bitter']

foodA.flavor.all() --> ['spicy', 'sweet']

foodB.flavor.all() --> ['spicy, 'bitter']

foodC.flavor.all() --> ['bitter', 'greasy']

I'd like to use Django's filter on Food.objects so that it would return a QuerySet containing foodA and foodB.

I understand I can achieve a similar result if I convert the user's flavors into a set, and call issuperset on each of the food's list of flavors (and add such food to a pre-defined list), but I'm wondering (and hoping) if there's a more graceful solution involving django model's filter function, something that will return me a QuerySet instead of a list.

Thank you very much in advance for your help.

答:
I don't think you can achieve what you're after just using the django orm. It'd somehow involve generating SQL which was capable of checking whether a result set is a superset of another result set. This would be possible (in sql) if you could rotate a result set. SQL Server has the PIVOT and UNPIVOT operators which can do this (other DBMS packages probably have similar operators), but django isn't capable of generating such SQL. I doubt any general purpose ORM would be capable of this.

The solution you're already aware of is quite elegant enough already. Two queries are enough to get all the data required, and then a general purpose language can much more easily determine set membership. Doing so in SQL would be a bit of a nightmare (I think).

Good question though. I started writing out SQL to achieve the result until I realised it was going to be a lot more trouble than I have time for without getting paid (and probably way out of my depth!). It'd be very interesting to see a pure sql solution if anyone posts it though.


问:
Best practice to implement a spring bean
I have got a mapper class which does a complex mapping of one pojo to another. I made the mapper class a bean and wired it to the service class. I could have made the mapper class a static class as well but I preferred a bean because I felt it better in a testability point of view, I can test the service and mappers independently by mocking the mappers. Indeed it’s also possible to mock the static classes but I will have to use powermock or something similar. Another reason to choose a bean is that for certain mappers I had to use interfaces so that I can choose the mapper implementation based on certain data conditions. </p>

<p>This implementation as a bean has triggered a controversy in my team with suggestions to implement it as a class with static map method or to create new mapper objects every time. And we are trying to figure out what is the best solution. Are there any industry standards being followed. Are there any trade offs with the beans approach? Can it have any impact on the performance of my application? imagine that I have got a hundred such mappers. Below is a simple Skelton of how my service and mappers looks like. </p>

```<code>@Service
class CustomerService { @Autowired CustomerMapper customerMapper ...}

@Component
class CustomerMapper { @Autowired CustomerContactMapper ..
}

interface CustomerContactMapper {}

@Component
class InternalCustomerContactMapper implements CustomerContactMapper {}

@Component
class ExternalCuatomerContactMapper implements CustomerContactMapper {}
</code>```

答:
Well, there can be many opinions, if you want to follow conventions suggested by spring, then you did everything right.

Basically your point of testability is valid although its better to use constructor injection in this case because in the unit test you see exactly what is the required dependency:

```<code>class CustomerService {
    private final CustomerMapper customerMapper;

    public CustomerService(CustomerMapper customerMapper) {
        this.customerMapper = customerMapper;
    }
}
</code>```

Side note: if you don't like the "boilerplate" of constructor, you can use Lombok that provides "AllArgsConstructor" anyway.

Now some points regarding the performance:
Spring initializes beans during the startup of the application. If these are simple-to-create classes (classes that do not load a lot of stuff upon creation, don't go to the db and so forth, just plain java objects) than it takes particles of second to initialize them all.

Later you have a regular function call (ok, if you work with interface then its a "virtual" call), but in general it doesn't affect the performance, in other words if the app works slow, the reason is likely to be anywhere else.

Regarding the alternative:

I didn't totally understand what does it mean "implement as a static class", however if you want to create a new mapper every time, this would mean that its not thread safe. In the current implementation the service is a singleton, so there won't be many instances of it, it will be only one instance per application context. However it can be called by many threads simultaneously.

So if you have to create many instances -> the mapper can't be used from many threads. This decision has nothing to do with Spring, its your code and your decision to make it non-thread safe (I'm not saying whether its good or bad, just stating the fact).

Now, if this is the case, then your solution is technically wrong. Spring supports this kind of usage via Provider class + there are other ways to inject prototype into singleton:

```<code>class CustomerService {
    private final Provider<CustomerMapper> customerMapper;
</code>```

You can read Here about this method

Body:
I have got a mapper class which does a complex mapping of one pojo to another. I made the mapper class a bean and wired it to the service class. I could have made the mapper class a static class as well but I preferred a bean because I felt it better in a testability point of view, I can test the service and mappers independently by mocking the mappers. Indeed it’s also possible to mock the static classes but I will have to use powermock or something similar. Another reason to choose a bean is that for certain mappers I had to use interfaces so that I can choose the mapper implementation based on certain data conditions.

This implementation as a bean has triggered a controversy in my team with suggestions to implement it as a class with static map method or to create new mapper objects every time. And we are trying to figure out what is the best solution. Are there any industry standards being followed. Are there any trade offs with the beans approach? Can it have any impact on the performance of my application? imagine that I have got a hundred such mappers. Below is a simple Skelton of how my service and mappers looks like.

@Service
class CustomerService { @Autowired CustomerMapper customerMapper ...}

@Component
class CustomerMapper { @Autowired CustomerContactMapper ..
}

interface CustomerContactMapper {}

@Component
class InternalCustomerContactMapper implements CustomerContactMapper {}

@Component
class ExternalCuatomerContactMapper implements CustomerContactMapper {}

Body:
Well, there can be many opinions, if you want to follow conventions suggested by spring, then you did everything right.

Basically your point of testability is valid although its better to use constructor injection in this case because in the unit test you see exactly what is the required dependency:

class CustomerService {
    private final CustomerMapper customerMapper;

    public CustomerService(CustomerMapper customerMapper) {
        this.customerMapper = customerMapper;
    }
}

Side note: if you don't like the "boilerplate" of constructor, you can use Lombok that provides "AllArgsConstructor" anyway.

Now some points regarding the performance:
Spring initializes beans during the startup of the application. If these are simple-to-create classes (classes that do not load a lot of stuff upon creation, don't go to the db and so forth, just plain java objects) than it takes particles of second to initialize them all.

Later you have a regular function call (ok, if you work with interface then its a "virtual" call), but in general it doesn't affect the performance, in other words if the app works slow, the reason is likely to be anywhere else.

Regarding the alternative:

I didn't totally understand what does it mean "implement as a static class", however if you want to create a new mapper every time, this would mean that its not thread safe. In the current implementation the service is a singleton, so there won't be many instances of it, it will be only one instance per application context. However it can be called by many threads simultaneously.

So if you have to create many instances -> the mapper can't be used from many threads. This decision has nothing to do with Spring, its your code and your decision to make it non-thread safe (I'm not saying whether its good or bad, just stating the fact).

Now, if this is the case, then your solution is technically wrong. Spring supports this kind of usage via Provider class + there are other ways to inject prototype into singleton:

class CustomerService {
    private final Provider<CustomerMapper> customerMapper;

You can read Here about this method


问:
How to get short URL link in android using Firebase Dynamic Links?
I'm trying to share a link which would redirect a user to YouTube link if clicked on a desktop browser and redirect to the app if clicked on Android.The links are working fine but I'm getting the deep link instead of short link

```<code>Uri uri = getIntent().getData();
String path = uri.getPath();
</code>```

Is there a way to get the short link in android ?

答:
How about you try this to get the link in your android app.</p>

```<code>FirebaseDynamicLinks.getInstance()
        .getDynamicLink(intent)
        .addOnSuccessListener(this) { pendingDynamicLinkData ->
            var deepLink: Uri? = null
            if (pendingDynamicLinkData != null) {
                deepLink = pendingDynamicLinkData.link
                Log.d("LINK :: ", deepLink)
            }
        }
        .addOnFailureListener(this) { e -> Log.d("Error", e) }
</code>```

Body:
I'm trying to share a link which would redirect a user to YouTube link if clicked on a desktop browser and redirect to the app if clicked on Android.The links are working fine but I'm getting the deep link instead of short link

Uri uri = getIntent().getData();
String path = uri.getPath();

Is there a way to get the short link in android ?

Body:
How about you try this to get the link in your android app.

FirebaseDynamicLinks.getInstance()
        .getDynamicLink(intent)
        .addOnSuccessListener(this) { pendingDynamicLinkData ->
            var deepLink: Uri? = null
            if (pendingDynamicLinkData != null) {
                deepLink = pendingDynamicLinkData.link
                Log.d("LINK :: ", deepLink)
            }
        }
        .addOnFailureListener(this) { e -> Log.d("Error", e) }


问:
WCF Load Testing
I am using WCF service with TCP binding and want to do load testing, can anybody please guide, how to perform it and i want to do it on free tool. I tried with VS 2010 but it didnt work because of TCP binding</p>

答:
I'd recommend a different approach to your load testing plan. Add a wsHttpBinding endpoint to your services and use something like this free tool to do the load testing over HTTP instead of TCP. The netTcpBinding will virtually always be faster than the HTTP based bindings but not nearly as dramatically as you'd think and probably not enough to make your load test results inaccurate.

With the HTTP based load tests you'll have more options for tools to use. Remember that you are trying to determine the performance profile of your code not the WCF framework itself. You'll still want to do some results validation with the netTcpBinding using something along the lines of what @PeytonCrow mentions in his comment to the question.

Title: WCF Load Testing


问:
How to identify an excel file(xls, xlsx, csv) which has been converted from .DLL file in c# dot net core
Basically need to identify the excel is originally created from a valid excel. I have tried using Microsoft.Interop.Excel File format.
Seems like I cannot use this without Microsoft office being installed. So need another approach for this problem.

EDIT :
Basically I want to be able to distinguish a valid excel from invalid one like an excel file which is converted from DLL. Because the file extension will say it is xls. If you try to open that file, it will open an empty workbook without any sheets. But I cannot decide an excel with no sheets is an invalid one.

答:
If you want to idenify wheter file is a valid excel file or not, you can use 'trid file identifier'. TrID - File Identifier. </p>

<p>You can do it own your own also by reading magic number or file signaure bytes. Please go through this question Original file bytes from StreamReader, magic number detection.    </p>

Body:
If you want to idenify wheter file is a valid excel file or not, you can use 'trid file identifier'. TrID - File Identifier.

You can do it own your own also by reading magic number or file signaure bytes. Please go through this question Original file bytes from StreamReader, magic number detection.