问:
Error creating bean with name entityManagerFactory with PostgreSQL and Spring Boot project
Error comes when I try to compile the project</p>
```<code>Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-11 15:21:24.256 ERROR 14192 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at com.example.spring_appdemo.SpringAppDemoApplication.main(SpringAppDemoApplication.java:15) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 33 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 47 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[na:na]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.<init>(HibernateJpaVendorAdapter.java:84) ~[spring-orm-5.3.15.jar:5.3.15]
    at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.createJpaVendorAdapter(HibernateJpaConfiguration.java:125) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:105) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 48 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    ... 65 common frames omitted

Process finished with exit code 1
</code>```
```<code>pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>Spring_appDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Spring_appDemo</name>
    <description>Spring_appDemo</description>
    <properties>
        <java.version>11</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>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.11.Final</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

答: The reason of the error — you are using incorrect dependencies in pom.xml. Please, don't add Hibernate dependencies manually. They are added by spring-boot-starter-data-jpa. Remove hibernate-core from pom.xml please.

Body:
Error comes when I try to compile the project

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-11 15:21:24.256 ERROR 14192 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at com.example.spring_appdemo.SpringAppDemoApplication.main(SpringAppDemoApplication.java:15) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 33 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 47 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/jpa/HibernatePersistenceProvider
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[na:na]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.<init>(HibernateJpaVendorAdapter.java:84) ~[spring-orm-5.3.15.jar:5.3.15]
    at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.createJpaVendorAdapter(HibernateJpaConfiguration.java:125) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:105) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 48 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    ... 65 common frames omitted

Process finished with exit code 1

pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.3</version>
        <relativePath/>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>Spring_appDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Spring_appDemo</name>
    <description>Spring_appDemo</description>
    <properties>
        <java.version>11</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>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.11.Final</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
        </plugins>
    </build>

</project>


来源: stackexchange

问:
In C# string how to replace two chararacters ignoring a number
I am editing a serialized string becuase when deserilized it gives a parse error.
so from a long Serialized string I want to edit "myVar\": \"0.2 mm" with "myVar\": \"0.2"
if I use the follwoing code it works

```<code>string NewString = Serializedstring.Replace($"myVar\": \"0.2 mm", $"myVar\": \"0.2")
</code>```

but my 0.2 is a varible that may change with every occurance. so all I want is to remove mm from the string "myVar\": \"0.2 mm"

答:
I can recommend 2 alternate approaches

1)match what you can.
var str = NewString.Replace(" mm,\"", "");
if your string is not going to have a space followed by mm" anywhere else that should be fine.

2)A safer option would be to deserialize it into something that can handle it (i assume your deserializing that property to a number currently) and then string replace the property and map it to what you need it.

ContentLicense: CC BY-SA 4.0

Body:
I am editing a serialized string becuase when deserilized it gives a parse error.
so from a long Serialized string I want to edit "myVar\": \"0.2 mm" with "myVar\": \"0.2"
if I use the follwoing code it works

string NewString = Serializedstring.Replace($"myVar\": \"0.2 mm", $"myVar\": \"0.2")

but my 0.2 is a varible that may change with every occurance. so all I want is to remove mm from the string "myVar\": \"0.2 mm"


问:
FLUTTER Android Studio BUMBLEBEE: Generating signed bundle requires you to update the Android Gradle plugin to version 3.2.0 or higher
When I try to build > generate signed bundle
AS complains:

Generating signed bundle requires you to update the Android Gradle
plugin to version 3.2.0 or higher

If I click on Close this dialog and update the plugin
A further dialog appears (AS Bumblebee) titled update the Android Gradle plugin If I hit OK, the dialog vanishes, nothing happens, and I get the same complaint when I try to build a signed app bundle again.

This is really frustrating because I can't upload an app with Googlemaps without signing it. That's my whole app!

OK well similar problems have been answered a few times on StackOverflow, but some of the solutions have become antiquated other solutions don't seem relevant:

I can see no way to update Gradle through File > project structure in Android Studio Bumblebee.

If I try and update Gradle manually in android/build.gradle, well it already has gradle 7.03, which is way above 3.2.0. Although Gradle and Android Studio's Gradle plugin may have different version numbers. See the code snippet below.

I've tried using Android Studio's search box with 'update Gradle plugin' to no effect.

I've hunted around Preferences > SDK tools, but no mention of a gradle plugin.

Instead of using an app bundle I've tried generating a signed APK, but that has problems too, and the file is larger, so no easy solution.

This is the relevant part of my android/build.gradle file:

```<code>dependencies {
    classpath 'com.android.tools.build:gradle:7.0.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.5'
}
</code>```

FURTHER investigation, gradle-wrapper.properties contains this:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

Which is a different version number to my android/build.gradle:

classpath 'com.android.tools.build:gradle:7.0.3'

I'm not sure why they have different numbers.

This is the last hurdle for one app, and a roadblock in another, please help. I'm totally lost, I've begun to think maybe a Kotlin plugin upgrade has caused havoc somehow.

UPDATE
I've reported the issue to Google, via AS's help menu, and in doing so the report said this...

AS: Bumblebee | 2021.1.1; Kotlin plugin:
211-1.6.10-release-923-AS7442.40; Android Gradle Plugin: (plugin
information not found); Gradle: (gradle version information not
found); Gradle JDK: version 11.0.11; NDK: from local.properties: (not
specified), latest from SDK: (not found); LLDB: pinned revision 3.1
not found, latest from SDK: (package not found); CMake: from
local.properties: (not specified), latest from SDK: (not found), from
PATH: (not found)

That's a lot of things missing! Both gradle and the gradle plugin. I've tried creating a fresh project in AS Bumblebee then asking for a signed bundle but get the same complaint, so it's not because the projects have taken a while.

Any solutions are appreciated. I thought you just downloaded Android Studio and it was all good to go... sigh.

UPDATE attempted the solution offered below, but I do not appear to have a Gradle location set, as per picture...

Buidl, execution, deployment > build tools > gradle" />

答:
Well in the end I solved it. In the left hand project files pane I right-clicked on Android > Open in Android Studio, Gradle then took a long time reindexing the project and offered to update the project's Gradle version, which this time it did successfully. HALLEYUH!

I seldom push out signed apps, so I'd forgotten the process for doing this, and the fact that the AS Flutter plugin offered me the option of Tools > build signed app bundle within the plugin led me away from how I've successfully attained a signed app in the past.

I think really the Flutter team shouldn't offer this option if it's not going to work reliably, but the solution is to do it the old way. Change the IDE back into what I presume is 'Java app' view, and be patient while AS runs around fetching gradle and Android SDK updates, reindexing.  Then seek  Build > signed app bundle from there.

Thanks everybody for your attention, and apologies for wasting energies. x Sam

Body:
When I try to build > generate signed bundle
AS complains:

Generating signed bundle requires you to update the Android Gradle
plugin to version 3.2.0 or higher

If I click on Close this dialog and update the plugin
A further dialog appears (AS Bumblebee) titled update the Android Gradle plugin If I hit OK, the dialog vanishes, nothing happens, and I get the same complaint when I try to build a signed app bundle again.

This is really frustrating because I can't upload an app with Googlemaps without signing it. That's my whole app!

OK well similar problems have been answered a few times on StackOverflow, but some of the solutions have become antiquated other solutions don't seem relevant:

I can see no way to update Gradle through File > project structure in Android Studio Bumblebee.

If I try and update Gradle manually in android/build.gradle, well it already has gradle 7.03, which is way above 3.2.0. Although Gradle and Android Studio's Gradle plugin may have different version numbers. See the code snippet below.

I've tried using Android Studio's search box with 'update Gradle plugin' to no effect.

I've hunted around Preferences > SDK tools, but no mention of a gradle plugin.

Instead of using an app bundle I've tried generating a signed APK, but that has problems too, and the file is larger, so no easy solution.

This is the relevant part of my android/build.gradle file:

dependencies {
    classpath 'com.android.tools.build:gradle:7.0.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.5'
}

FURTHER investigation, gradle-wrapper.properties contains this:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

Which is a different version number to my android/build.gradle:

classpath 'com.android.tools.build:gradle:7.0.3'

I'm not sure why they have different numbers.

This is the last hurdle for one app, and a roadblock in another, please help. I'm totally lost, I've begun to think maybe a Kotlin plugin upgrade has caused havoc somehow.

UPDATE
I've reported the issue to Google, via AS's help menu, and in doing so the report said this...

AS: Bumblebee | 2021.1.1; Kotlin plugin:
211-1.6.10-release-923-AS7442.40; Android Gradle Plugin: (plugin
information not found); Gradle: (gradle version information not
found); Gradle JDK: version 11.0.11; NDK: from local.properties: (not
specified), latest from SDK: (not found); LLDB: pinned revision 3.1
not found, latest from SDK: (package not found); CMake: from
local.properties: (not specified), latest from SDK: (not found), from
PATH: (not found)

That's a lot of things missing! Both gradle and the gradle plugin. I've tried creating a fresh project in AS Bumblebee then asking for a signed bundle but get the same complaint, so it's not because the projects have taken a while.

Any solutions are appreciated. I thought you just downloaded Android Studio and it was all good to go... sigh.

UPDATE attempted the solution offered below, but I do not appear to have a Gradle location set, as per picture...

Buidl, execution, deployment > build tools > gradle" />


问:
React Native - When I run 'detox build -c android' it says "The system cannot find the path specified"
So I've essentially followed all the instructions in the Detox documentation for getting a Detox testing environment and suite set up for Android in a React Native project. For my Android setup, I added the native detox dependency to my root build.gradle. I did NOT set up Detox as a compiling dependency because the docs said it was an alternative way to set it up instead of adding Detox as a dependency to the root build.gradle which is what I did.

This is my detoxrc.json:

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "devices": {
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_5_API_30"
      }
    }
  },
  "apps": {
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd .."
    }
  },
  "configurations": {
    "android": {
      "device": "emulator",
      "app": "android"
    }
  }
}

```
<p>I know for a fact that my <code>app-debug.apk</code> is in <code>android/app/build/outputs/apk/debug/app-debug.apk</code> because I can see it there. Yet when I run my script for <code>detox build -c android</code> this is the output:</p>
<pre class="lang-sh prettyprint-override"><code>$ yarn e2e:build-android
yarn run v1.22.17
$ detox build --configuration android
detox[19708] INFO:  [build.js] cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..
The system cannot find the path specified.
detox[19708] WARN:  [build.js]

Important: 'detox build' is a convenience shortcut for calling your own build command, as provided in the config file.
Failures in this build command are not the responsibility of Detox. You are responsible for maintaining this command.

detox[19708] ERROR: [cli.js] Command failed: cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

</code>```

The yarn e2e:build-android command is just a custom script I defined my root package.json as detox build --configuration android. So it looks like my problem is that The system cannot find the path specified. But as I've stated earlier I can see my app-debug.apk in android/app/build/outputs/apk/debug/app-debug.apk so I know for sure it is in there and that it is the correct path.

I think the issue might have to do with the way my project is structured and where I chose to install the dependencies for detox and jest. I installed detox, jest, & jest-circus in my root package.json but this app is a hybrid mobile/web application so the path to my ouput apk is in the mobile package. When I ran yarn e2e:build-android obviously I was doing that from my root folder which is where detox is installed.

Here is what my project structure looks like:

```<code>
V2 /
|--e2e
|--node_modules
|--packages
|   |--common
|   |--mobile
|   |--web
|--detoxrc.json
|--package.json <--- root pkg.json where I installed detox, jest, & jest-circus as devDep

</code>```

This is my root package.json looks like:

{
  "name": "root",
  "private": true,
  "devDependencies": {
    "detox": "^19.4.4",
    "jest": "^27.5.1",
    "jest-circus": "^27.5.1",
    "lerna": "^4.0.0"
  },
  "scripts": {
    "reinstall": "rm -rf ./packages/*/node_modules && rm -rf ./node_modules && yarn",
    "clean": "npx react-native-clean-project",
    "e2e:build-ios": "detox build --configuration ios",
    "e2e:build-android": "detox build --configuration android",
    "e2e:run-ios": "detox test --configuration ios",
    "e2e:run-android": "detox test --configuration android"
  },
  "workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/react-native",
      "**/react-native/**",
      "**/react-redux",
      "**/react-redux/**",
      "**/@reduxjs/toolkit",
      "**/@reduxjs/toolkit/**",
      "**/react-dom",
      "**/react-dom/**",
      "**/native-base",
      "**/native-base/**",
      "**/react-native-svg",
      "**/react-native-svg/**",
      "**/react-native-safe-area-context",
      "**/react-native-safe-area-context/**",
      "**/react-native-web",
      "**/react-native-web/**",
      "**/axios",
      "**/axios/**",
      "**/i18next",
      "**/i18next/**",
      "**/react-i18next",
      "**/react-i18next/**"
    ]
  }
}
```

So the full path to my app-debug.apk is V2\packages\mobile\android\app\build\outputs\apk\debug\app-debug.apk and I've even tried specifying the full path in my detoxrc.json's binaryBath field but that did not work either. So I don't know what else the problem could be, but I guess it's possible that Detox just doesn't work with the most recent version of react-native which is v0.67.1 which is what I'm using.

So my official question is what else could this issue be related to?

答:
I guess you have copied setup from youtube tutorial. I had similar problem.
Instead of yarn e2e:build-android.
run yarn android. (this will build your app)
then followed by yarn e2e:run-android.

detoxrc.json

```<code>{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "apps": {
    "ios": {
      "type": "ios.app",
      "binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY",
      "build": "xcodebuild -workspace ios/JSMarathon.xcworkspace -configuration Release -sdk iphonesimulator -derivedDataPath ios/build  -scheme JSMarathon"
    },
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -"
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 12"
      }
    },
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_3a_API_30"
      }
    }
  },
  "configurations": {
    "ios": {
      "device": "simulator",
      "app": "ios"
    },
    "android": {
      "device": "emulator",
      "app": "android"
    }
  }
}
</code>```

Body:
So I've essentially followed all the instructions in the Detox documentation for getting a Detox testing environment and suite set up for Android in a React Native project. For my Android setup, I added the native detox dependency to my root build.gradle. I did NOT set up Detox as a compiling dependency because the docs said it was an alternative way to set it up instead of adding Detox as a dependency to the root build.gradle which is what I did.

This is my detoxrc.json:

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "devices": {
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_5_API_30"
      }
    }
  },
  "apps": {
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd .."
    }
  },
  "configurations": {
    "android": {
      "device": "emulator",
      "app": "android"
    }
  }
}

I know for a fact that my app-debug.apk is in android/app/build/outputs/apk/debug/app-debug.apk because I can see it there. Yet when I run my script for detox build -c android this is the output:

$ yarn e2e:build-android
yarn run v1.22.17
$ detox build --configuration android
detox[19708] INFO:  [build.js] cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..
The system cannot find the path specified.
detox[19708] WARN:  [build.js]

Important: 'detox build' is a convenience shortcut for calling your own build command, as provided in the config file.
Failures in this build command are not the responsibility of Detox. You are responsible for maintaining this command.

detox[19708] ERROR: [cli.js] Command failed: cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The yarn e2e:build-android command is just a custom script I defined my root package.json as detox build --configuration android. So it looks like my problem is that The system cannot find the path specified. But as I've stated earlier I can see my app-debug.apk in android/app/build/outputs/apk/debug/app-debug.apk so I know for sure it is in there and that it is the correct path.

I think the issue might have to do with the way my project is structured and where I chose to install the dependencies for detox and jest. I installed detox, jest, & jest-circus in my root package.json but this app is a hybrid mobile/web application so the path to my ouput apk is in the mobile package. When I ran yarn e2e:build-android obviously I was doing that from my root folder which is where detox is installed.

Here is what my project structure looks like:

V2 /
|--e2e
|--node_modules
|--packages
|   |--common
|   |--mobile
|   |--web
|--detoxrc.json
|--package.json <--- root pkg.json where I installed detox, jest, & jest-circus as devDep

This is my root package.json looks like:

{
  "name": "root",
  "private": true,
  "devDependencies": {
    "detox": "^19.4.4",
    "jest": "^27.5.1",
    "jest-circus": "^27.5.1",
    "lerna": "^4.0.0"
  },
  "scripts": {
    "reinstall": "rm -rf ./packages/*/node_modules && rm -rf ./node_modules && yarn",
    "clean": "npx react-native-clean-project",
    "e2e:build-ios": "detox build --configuration ios",
    "e2e:build-android": "detox build --configuration android",
    "e2e:run-ios": "detox test --configuration ios",
    "e2e:run-android": "detox test --configuration android"
  },
  "workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/react-native",
      "**/react-native/**",
      "**/react-redux",
      "**/react-redux/**",
      "**/@reduxjs/toolkit",
      "**/@reduxjs/toolkit/**",
      "**/react-dom",
      "**/react-dom/**",
      "**/native-base",
      "**/native-base/**",
      "**/react-native-svg",
      "**/react-native-svg/**",
      "**/react-native-safe-area-context",
      "**/react-native-safe-area-context/**",
      "**/react-native-web",
      "**/react-native-web/**",
      "**/axios",
      "**/axios/**",
      "**/i18next",
      "**/i18next/**",
      "**/react-i18next",
      "**/react-i18next/**"
    ]
  }
}

So the full path to my app-debug.apk is V2\packages\mobile\android\app\build\outputs\apk\debug\app-debug.apk and I've even tried specifying the full path in my detoxrc.json's binaryBath field but that did not work either. So I don't know what else the problem could be, but I guess it's possible that Detox just doesn't work with the most recent version of react-native which is v0.67.1 which is what I'm using.

So my official question is what else could this issue be related to?

Body:
I guess you have copied setup from youtube tutorial. I had similar problem.
Instead of yarn e2e:build-android.
run yarn android. (this will build your app)
then followed by yarn e2e:run-android.

detoxrc.json

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "apps": {
    "ios": {
      "type": "ios.app",
      "binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY",
      "build": "xcodebuild -workspace ios/JSMarathon.xcworkspace -configuration Release -sdk iphonesimulator -derivedDataPath ios/build  -scheme JSMarathon"
    },
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -"
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 12"
      }
    },
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_3a_API_30"
      }
    }
  },
  "configurations": {
    "ios": {
      "device": "simulator",
      "app": "ios"
    },
    "android": {
      "device": "emulator",
      "app": "android"
    }
  }
}


问:
Howto create PrincipalContext to Synology LDAP Server
I get stuck with following problem:

I want to use Synologys LDAP Service. Works fine. My config is:

FDQN: "ldap.local"

Base DN: "dc=ldap,dc=local"

Bind DN: "uid=root,cn=users,dc=ldap,dc=local"

allow anonymous (only for test !) don't force SSL

Now I have to check credentials from my c# .net application (.net 6). I would prefer using PrincipalContext rather than ldapconnection. But Whatever I do to create the PrincipalContext I always get errors. My code is:

```<code>string Domain = "192.168.178.79:389";//"192.168.178.79:636";
string dn = "dc=ldap,dc=local";
string User = "uid=admin,cn=users,dc=ldap,dc=local";
string Password = "iWillNotTellYouHere";
ContextOptions options = ContextOptions.SimpleBind;// | ContextOptions.SecureSocketLayer;
PrincipalContext context = new PrincipalContext(ContextType.Domain, Domain, dn, options, User, Password);
</code>```

The constructor crashes with NullReferenceException

I checked connection with Softerra LDAP Browser and it works fine with and without SSL. Using following params:

Host and base DN from above, default port

URL = "ldaps://192.168.178.79:636/dc=ldap,dc=local"

Auth simple

Principal = "uid=admin,cn=users,dc=ldap,dc=local"

the global LDAP password, which I wont tell here

Any Ideas ???

The stack trace is:

```<code>System.NullReferenceException
  HResult=0x80004003
  Nachricht = Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
  Quelle = System.DirectoryServices.AccountManagement
  Stapelüberwachung:
   at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
   at DomainTest.Form1.button3_Click(Object sender, EventArgs e) in N:\Matthias\source\repos\DomainTest\DomainTest\Form1.cs:line 35
</code>```

答:
OK now I know the problem source:

PrincipalContext can't handle OpenLDAP connections

I will have to use DirectoryEntry

Body:
I get stuck with following problem:

I want to use Synologys LDAP Service. Works fine. My config is:

FDQN: "ldap.local"

Base DN: "dc=ldap,dc=local"

Bind DN: "uid=root,cn=users,dc=ldap,dc=local"

allow anonymous (only for test !) don't force SSL

Now I have to check credentials from my c# .net application (.net 6). I would prefer using PrincipalContext rather than ldapconnection. But Whatever I do to create the PrincipalContext I always get errors. My code is:

string Domain = "192.168.178.79:389";//"192.168.178.79:636";
string dn = "dc=ldap,dc=local";
string User = "uid=admin,cn=users,dc=ldap,dc=local";
string Password = "iWillNotTellYouHere";
ContextOptions options = ContextOptions.SimpleBind;// | ContextOptions.SecureSocketLayer;
PrincipalContext context = new PrincipalContext(ContextType.Domain, Domain, dn, options, User, Password);

The constructor crashes with NullReferenceException

I checked connection with Softerra LDAP Browser and it works fine with and without SSL. Using following params:

Host and base DN from above, default port

URL = "ldaps://192.168.178.79:636/dc=ldap,dc=local"

Auth simple

Principal = "uid=admin,cn=users,dc=ldap,dc=local"

the global LDAP password, which I wont tell here

Any Ideas ???

The stack trace is:

System.NullReferenceException
  HResult=0x80004003
  Nachricht = Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
  Quelle = System.DirectoryServices.AccountManagement
  Stapelüberwachung:
   at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
   at DomainTest.Form1.button3_Click(Object sender, EventArgs e) in N:\Matthias\source\repos\DomainTest\DomainTest\Form1.cs:line 35


问:
aws Presigned Url doesn't support videos that are more than 1 minute long
enter image description hereWhen I tried creating Presigned URLs for my videos in s3 some of the video's presigned urls don't work. and It turned out that only URl of videos that are more then 1 minute long. Is there a problem  on my side while creating the url or is it a restriction in AWS presigned URLs</p>

答:
have you tried using readStream ?

rn-fetch-blob

Worked for me with having larger Videos or Images


问:
How to set iOS status bar background color in React Native?
Is there a single place in the react native iOS native code that I could modify to set iOS statusbar backgroundColor? RCTRootView.m ?

The react native StatusBar component only support backgroundColor for Android only.

The iOS operating system seems to allow setting status bar backgroundColor

My goal is to have a darker status bar color.

答:
If you are using React Navigation it is really easy!

Just set the headerStyle, see also documentation here.

Something like

```<code><Stack.Navigator initialRouteName="Home">
  <Stack.Screen
    name="Home"
    component={HomeScreen}
    options={{
      title: 'my app',
      headerStyle: {
        backgroundColor: 'green',
      },
    }}
  />
</Stack.Navigator>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
If you are using React Navigation it is really easy!

Just set the headerStyle, see also documentation here.

Something like

<Stack.Navigator initialRouteName="Home">
  <Stack.Screen
    name="Home"
    component={HomeScreen}
    options={{
      title: 'my app',
      headerStyle: {
        backgroundColor: 'green',
      },
    }}
  />
</Stack.Navigator>


问:
How to add a link to download a pdf file nuxt?
I just wants to add a link to download a pdf file in nuxt project.

How do I do that?

I have tried the following:

```<code><a :href="require('@/static/documents/WTSDL2019_Pamplet.pdf')" download class="btn btn-sm btn-sub-color" >Download</a>
</code>```

which works well for images but not for pdf files. I found vue-pdf but I feel its an extra work for the purpose of just linking a pdf file. I have no work view a pdf files with all those events.

答:
In my scenario, when I put file (1111.pdf) in sub-folder of static; like this static/pdf/1111.pdf , It doesn't response anything. But when I change to this  1111.pdf file to just under static folder, It works.
This is my code:

```<code><a href="../../1111.pdf" download="" target="_blank" >Download</a>
</code>```

Body:
I just wants to add a link to download a pdf file in nuxt project.

How do I do that?

I have tried the following:

Download

which works well for images but not for pdf files. I found vue-pdf but I feel its an extra work for the purpose of just linking a pdf file. I have no work view a pdf files with all those events.

Body:
In my scenario, when I put file (1111.pdf) in sub-folder of static; like this static/pdf/1111.pdf , It doesn't response anything. But when I change to this  1111.pdf file to just under static folder, It works.
This is my code:

<a href="../../1111.pdf" download="" target="_blank" >Download</a>


问:
Set legend width to be 100% plot width
How do I set the legend height or width to be 100% of the plot height/width regardless of the actual dimensions?

library(ggplot2)
ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point()+
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.key.width=unit(0.1,"npc"))
```
<p><img src="https://i.imgur.com/etPvIQL.png" alt="" /></p>
<p><sup>Created on 2022-02-11 by the reprex package (v2.0.1)</sup></p>

Session info

<pre class="lang-r prettyprint-override"><code>sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.0 (2021-05-18)
#>  os       Ubuntu 20.04.3 LTS
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.0)
#>
#> ──────────────────────────────────────────────────────────────────────────────
</code>```

答:
Please forgive me for double answers, but I believe this to be a totally different approach, and the credits for the idea go to @benson23.

We can use ggh4x::force_panelsizes() to set an absolute size for the panel and match the width of the bar. Upside is that it is reasonably easy to do, downside is that your plot's width doesn't automagically adapts to the window size anymore.

library(ggplot2)
library(ggh4x)

width <- unit(10, "cm")

ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point() +
  guides(colour = guide_colorbar(barwidth = width)) +
  force_panelsizes(cols = width) +
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.spacing.x = unit(0, "cm"))
```
<p><img src="https://i.imgur.com/X6idNqz.png" alt="" /></p>
<p>The process becomes slightly more complicated if a plot has multiple panels, but it is not undoable.</p>
<pre class="lang-r prettyprint-override"><code>ncol         <- 3
total_width  <- unit(10, "cm")
# Optionally: replace `theme_get()` with actual theme you're using
spacing      <- calc_element("panel.spacing.x", theme_get())
panel_widths <- (total_width - spacing * (ncol - 1)) / ncol

ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point() +
  guides(colour = guide_colorbar(barwidth = total_width)) +
  facet_wrap(~ Species, ncol = ncol) +
  force_panelsizes(cols = panel_widths) +
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.spacing.x = unit(0, "cm"))
</code>```

Created on 2022-02-11 by the reprex package (v2.0.1)

Disclaimer: I'm the author of {ggh4x}

Title: Set legend width to be 100% plot width

Body:
How do I set the legend height or width to be 100% of the plot height/width regardless of the actual dimensions?

library(ggplot2)
ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point()+
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.key.width=unit(0.1,"npc"))

Created on 2022-02-11 by the reprex package (v2.0.1)

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.0 (2021-05-18)
#>  os       Ubuntu 20.04.3 LTS
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.0)
#>
#> ──────────────────────────────────────────────────────────────────────────────

Body:
Please forgive me for double answers, but I believe this to be a totally different approach, and the credits for the idea go to @benson23.

We can use ggh4x::force_panelsizes() to set an absolute size for the panel and match the width of the bar. Upside is that it is reasonably easy to do, downside is that your plot's width doesn't automagically adapts to the window size anymore.

library(ggplot2)
library(ggh4x)

width <- unit(10, "cm")

ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point() +
  guides(colour = guide_colorbar(barwidth = width)) +
  force_panelsizes(cols = width) +
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.spacing.x = unit(0, "cm"))

The process becomes slightly more complicated if a plot has multiple panels, but it is not undoable.

ncol         <- 3
total_width  <- unit(10, "cm")
# Optionally: replace `theme_get()` with actual theme you're using
spacing      <- calc_element("panel.spacing.x", theme_get())
panel_widths <- (total_width - spacing * (ncol - 1)) / ncol

ggplot(iris, aes(Petal.Width, Sepal.Width, color=Petal.Length))+
  geom_point() +
  guides(colour = guide_colorbar(barwidth = total_width)) +
  facet_wrap(~ Species, ncol = ncol) +
  force_panelsizes(cols = panel_widths) +
  theme(
    legend.title=element_blank(),
    legend.position="bottom",
    legend.spacing.x = unit(0, "cm"))

Created on 2022-02-11 by the reprex package (v2.0.1)

Disclaimer: I'm the author of {ggh4x}


问:
Concatenate unicode character (warning sign) with string in javascript
I have a unicode character for warning sign- Unicode Character “⚠” (U+26A0)
https://www.compart.com/en/unicode/U+26A0

I am trying to append this to a string variable but i am not successful in appending the image
Can anyone let me know how to append it here, Also i am trying to make the warning sign yellow in color.

for e.g.
I want the result as -> ⚠ Warning Sign

I tried the following but didnt succeed

```<code>let result = `U+26A0` + 'Warning Sign'
</code>```

答:
You can use the String.fromCharCode(num1) method.

Edit:

That is, String.fromCharCode(0x26A0) + " Warning Sign"

Body:
I have a unicode character for warning sign- Unicode Character “⚠” (U+26A0)
https://www.compart.com/en/unicode/U+26A0

I am trying to append this to a string variable but i am not successful in appending the image
Can anyone let me know how to append it here, Also i am trying to make the warning sign yellow in color.

for e.g.
I want the result as -> ⚠ Warning Sign

I tried the following but didnt succeed

let result = `U+26A0` + 'Warning Sign'


问:
how to convert a sql server store procedure to mysql procedure?
I have to convert store procedure from that is written in sql server, to mysql procedure. I know the their general differences like AS, GO and ; but still mysql procedure has not the same result as sql server. It is noteworthy that tables and their data are the same. can anyone say other differences between them?
I will thank you if you tell me correct answer in this case</p>

答: I figure out for using mysql parameters like IN b INT in procedure code, I must use b directly! not @b like sql server


问:
jest describe suite fails but running test independently succeeds
When I run each test alone then they both succeed. But when I run them together by npm test the second test fails:

```<code>Expected number of calls: 2
Received number of calls: 4
</code>```

I have the following code: (short and cutted)

```<code>describe('checkDonations', () => {
test('it should call twice (test 1)', async () => {
    const axiosSpy = jest.spyOn(axios.default, 'get')
        .mockImplementation(() => {
            return new Promise(resolve => {
                resolve({
                    data: {
                        status: [
                            {
                                "created": "2020-04-08 21:20:17",
                                "timestamp": "1586373617",
                                "statusName": "new"
                            }
                        ]
                    }
                })
            })
        });

    await checkDonations(null, {});

    expect(axiosSpy).toHaveBeenCalledTimes(2);
})

test('it should call twice (test 2)', async () => {
    const axiosSpy = jest.spyOn(axios.default, 'get')
        .mockImplementation(() => {
            return new Promise(resolve => {
                resolve({
                    data: {
                        status: [
                            {
                                "created": "2020-04-08 21:20:17",
                                "timestamp": "1586373617",
                                "statusName": "final_success"
                            }
                        ]
                    }
                })
            })
        });

    await checkDonations(null, {});

    expect(axiosSpy).toHaveBeenCalledTimes(2);
})
})
</code>```

The tests are cutted to display the issue. As you can see they are almost equal and each one has his own const of spy. Only the return value of the axiosSpy different. So I cannot place it in before each.

Why does the second test fail when I run them by npm test ?

答: Delete the build-generated folder(egs: dist) and try again. It works for me.</p>

Body:
When I run each test alone then they both succeed. But when I run them together by npm test the second test fails:

Expected number of calls: 2
Received number of calls: 4

I have the following code: (short and cutted)

describe('checkDonations', () => {
test('it should call twice (test 1)', async () => {
    const axiosSpy = jest.spyOn(axios.default, 'get')
        .mockImplementation(() => {
            return new Promise(resolve => {
                resolve({
                    data: {
                        status: [
                            {
                                "created": "2020-04-08 21:20:17",
                                "timestamp": "1586373617",
                                "statusName": "new"
                            }
                        ]
                    }
                })
            })
        });

    await checkDonations(null, {});

    expect(axiosSpy).toHaveBeenCalledTimes(2);
})

test('it should call twice (test 2)', async () => {
    const axiosSpy = jest.spyOn(axios.default, 'get')
        .mockImplementation(() => {
            return new Promise(resolve => {
                resolve({
                    data: {
                        status: [
                            {
                                "created": "2020-04-08 21:20:17",
                                "timestamp": "1586373617",
                                "statusName": "final_success"
                            }
                        ]
                    }
                })
            })
        });

    await checkDonations(null, {});

    expect(axiosSpy).toHaveBeenCalledTimes(2);
})
})

The tests are cutted to display the issue. As you can see they are almost equal and each one has his own const of spy. Only the return value of the axiosSpy different. So I cannot place it in before each.

Why does the second test fail when I run them by npm test ?


问:
Can't install node-sass@6 for node v16
This is my package.json after uninstalling sass  node-sass and sass-loader because I changed my node version from 14 to 16,

```<code>{
  "name": "our-awesome-project",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "static": "NUXTJS_DEPLOY_TARGET=static NUXTJS_SSR=true nuxt generate",
    "build-and-start": "NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt build && NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt start"
  },
  "husky": {
    "hooks": {
      "pre-commit": "cross-env PRE_COMMIT=true lint-staged -r"
    }
  },
  "dependencies": {
    "core-js": "^3.19.3",
    "nuxt": "^2.15.8",
    "nuxt-i18n": "^6.28.1",
    "nuxt-purgecss": "^1.0.0",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46"
  },
  "devDependencies": {
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/google-fonts": "^1.3.0",
    "@nuxtjs/storybook": "^4.2.0",
    "@nuxtjs/style-resources": "^1.2.1",
    "@vue/cli-plugin-babel": "^4.5.15",
    "babel-eslint": "^10.1.0",
    "eslint": "^8.7.0",
    "husky": "^7.0.4",
    "nuxt-svg-loader": "^1.2.0",
    "postcss": "^8.4.5"
  }
}
</code>```

According to this I should install node-sass version 6.0

But I'm trying:
npm install --save-dev sass@1.49.0 node-sass@6.0.1 sass-loader@10.2.1

Also, read here to add --unsafe-perm so I tried:
npm install --save-dev --unsafe-perm sass@1.49.0 node-sass@6.0.1 sass-loader@10.2.1

But it keeps failing, being the first error always this one:

```<code>npm ERR! code 1
npm ERR! path /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/user/.nvm/versions/node/v16.13.1/bin/node /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
</code>```

I tried removing node_modules package-lock.json and the same result

Of course, this is driving me nuts.. please tell me that anyone has an idea to try out

答:
in fact , I think you have pasted the wrong error infomation.
there are two ways may help you

npm i --force this command will ignored the error in the package.json

use the pnpm , you can install it by

```<code>npm i -g pnpm
# then
pnpm i
</code>```

Title: Can't install node-sass@6 for node v16

Body:
This is my package.json after uninstalling sass  node-sass and sass-loader because I changed my node version from 14 to 16,

{
  "name": "our-awesome-project",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "static": "NUXTJS_DEPLOY_TARGET=static NUXTJS_SSR=true nuxt generate",
    "build-and-start": "NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt build && NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt start"
  },
  "husky": {
    "hooks": {
      "pre-commit": "cross-env PRE_COMMIT=true lint-staged -r"
    }
  },
  "dependencies": {
    "core-js": "^3.19.3",
    "nuxt": "^2.15.8",
    "nuxt-i18n": "^6.28.1",
    "nuxt-purgecss": "^1.0.0",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46"
  },
  "devDependencies": {
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/google-fonts": "^1.3.0",
    "@nuxtjs/storybook": "^4.2.0",
    "@nuxtjs/style-resources": "^1.2.1",
    "@vue/cli-plugin-babel": "^4.5.15",
    "babel-eslint": "^10.1.0",
    "eslint": "^8.7.0",
    "husky": "^7.0.4",
    "nuxt-svg-loader": "^1.2.0",
    "postcss": "^8.4.5"
  }
}

According to this I should install node-sass version 6.0

But I'm trying:
npm install --save-dev sass@1.49.0 node-sass@6.0.1 sass-loader@10.2.1

Also, read here to add --unsafe-perm so I tried:
npm install --save-dev --unsafe-perm sass@1.49.0 node-sass@6.0.1 sass-loader@10.2.1

But it keeps failing, being the first error always this one:

npm ERR! code 1
npm ERR! path /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/user/.nvm/versions/node/v16.13.1/bin/node /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

I tried removing node_modules package-lock.json and the same result

Of course, this is driving me nuts.. please tell me that anyone has an idea to try out

Body:
in fact , I think you have pasted the wrong error infomation.
there are two ways may help you

npm i --force this command will ignored the error in the package.json

use the pnpm , you can install it by

npm i -g pnpm
# then
pnpm i


问:
Insert a random value from a php array in MySQL?
I would like to insert a random value from a php array into a mysql table.

My php array is $profile_outM = (3,6,7)

The following command works nicely and sets user_profile to 7 for all users having user_UFR equal to 2:

UPDATE `users` SET `user_profile` = '$profile_outM[3]'  WHERE `user_UFR`= 2

But how can I select a random value from  $profile_outM ?

Best,

HERE is the solution (might not be very elegant / efficient) but it works:

Starting with $profile_outM as a string

I convert to an array and get the number of element

profile2array = explode(",", $profile_outM);

$length_profile2array =  count($profile2array);

Then

"SET @myValues = '$profile_outM'"

"UPDATE `users` SET `user_profile` = SUBSTRING_INDEX(REVERSE(SUBSTRING_INDEX(@Values, ',', FLOOR(1+RAND()*$length_profile2array))),',',1) WHERE `user_UFR`=2"

This way, all users get a different value.

W

答:
You can use array_rand() as @Victorbzh mentioned, or you can use:

```<code>$val = $array[mt_rand(0, count($array) - 1];
</code>```

The above generates a random number using mt_rand($min, $max) ($max is inclusive). Array indexes start from 0, and count() gets the number of elements in the array.

Security Note 1: array_rand() and mt_rand() do not generate cryptographically secure values. If you want cryptographically secure values, use random_int()

Security Note 2: UPDATE `users` SET `user_profile` = '$profile_outM[3]'  WHERE `user_UFR`= 2: It seems you are not using prepared statements. Make sure to use prepared statements when you are using input from the user.

Body:
You can use array_rand() as @Victorbzh mentioned, or you can use:

$val = $array[mt_rand(0, count($array) - 1];

The above generates a random number using mt_rand($min, $max) ($max is inclusive). Array indexes start from 0, and count() gets the number of elements in the array.

Security Note 1: array_rand() and mt_rand() do not generate cryptographically secure values. If you want cryptographically secure values, use random_int()

Security Note 2: UPDATE `users` SET `user_profile` = '$profile_outM[3]'  WHERE `user_UFR`= 2: It seems you are not using prepared statements. Make sure to use prepared statements when you are using input from the user.


问:
New FileStream already closed/disposed?
I open a FileStream with FileMode.Open and FileAccess.Read. Shortly after that I call a function to handle the file's contents. I use Invoke to make the call because the call comes from a Thread and the function has to put the results on a Form. The function accepts any kind of Stream (I call it with MemoryStreams too without a problem) and uses XmlTextReader to read the XML in the FileStream, but on rare occasions for unknown reasons even the first Read() throws an ObjectDisposedException and the stream's CanRead property returns false if the stream was already closed.

In the Thread the FileStream is a local using variable, so I don't think another threads should be able to close it, and I don't close it until the Invoke returned. There are no Exceptions thrown so the file is definetly there (since there is no FileNotFoundException) and should be accessed properly (since there is no UnauthorizedAccessException and IOException).

How could my FileStream still look closed sometimes just after opened?

(It might matter that I'm running my code on a Windows CE 5 device with Compact Framework 3.5 and I wasn't able to reproduce the same behaviour on my desktop PC with XP yet.)

EDIT:
I know, that this Invoke is ugly but that alone can't be a reason to fail, can it? (And, in most of the cases it doesn't fail at all.)

```<code>//the code in the thread
//...
using (FileStream fs = File.Open(assemblyPath + "\\white.xml", FileMode.Open, FileAccess.Read))
{
    mainForm.Instance.Invoke(new DataHandler(mainForm.Instance.handleData), new object[] { fs });
}
//...

//and the handler
public void handleData(Stream stream)
{
    infoPanel.SuspendLayout();
    try
    {
        using (XmlTextReader xml = new XmlTextReader(stream))
        {
            //it doesn't matter what is here
        }
    }
    catch{}
}
</code>```

答:
I saw the same issue on some embedded board (ARM) I'm working on. Then I created a little test.

The following code (not involving any Threads!) crashes:

```<code>    using (var w = new StreamWriter(File.Create("file.txt"), System.Text.Encoding.UTF8))
    {
        for (int i = 0; i < 1000; i++)
        {
            w.WriteLine("Test");
        }
    }
</code>```

This code however does not crash:

```<code>    using (var w = File.CreateText("file.txt"))
    {
        for (int i = 0; i < 1000; i++)
        {
            w.WriteLine("Test");
        }
    }
</code>```

So, my guess can only be that the underlying native code treats text files differently than when you open the file using File.Create(). Both files are then written in UTF-8, so there is no difference about the encoding.

BTW: sorry I'm one year late on the answer, but I hope it'll help somebody

ContentLicense: CC BY-SA 2.5

Title: New FileStream already closed/disposed?

Body:
I open a FileStream with FileMode.Open and FileAccess.Read. Shortly after that I call a function to handle the file's contents. I use Invoke to make the call because the call comes from a Thread and the function has to put the results on a Form. The function accepts any kind of Stream (I call it with MemoryStreams too without a problem) and uses XmlTextReader to read the XML in the FileStream, but on rare occasions for unknown reasons even the first Read() throws an ObjectDisposedException and the stream's CanRead property returns false if the stream was already closed.

In the Thread the FileStream is a local using variable, so I don't think another threads should be able to close it, and I don't close it until the Invoke returned. There are no Exceptions thrown so the file is definetly there (since there is no FileNotFoundException) and should be accessed properly (since there is no UnauthorizedAccessException and IOException).

How could my FileStream still look closed sometimes just after opened?

(It might matter that I'm running my code on a Windows CE 5 device with Compact Framework 3.5 and I wasn't able to reproduce the same behaviour on my desktop PC with XP yet.)

EDIT:
I know, that this Invoke is ugly but that alone can't be a reason to fail, can it? (And, in most of the cases it doesn't fail at all.)

//the code in the thread
//...
using (FileStream fs = File.Open(assemblyPath + "\\white.xml", FileMode.Open, FileAccess.Read))
{
    mainForm.Instance.Invoke(new DataHandler(mainForm.Instance.handleData), new object[] { fs });
}
//...

//and the handler
public void handleData(Stream stream)
{
    infoPanel.SuspendLayout();
    try
    {
        using (XmlTextReader xml = new XmlTextReader(stream))
        {
            //it doesn't matter what is here
        }
    }
    catch{}
}

Body:
I saw the same issue on some embedded board (ARM) I'm working on. Then I created a little test.

The following code (not involving any Threads!) crashes:

    using (var w = new StreamWriter(File.Create("file.txt"), System.Text.Encoding.UTF8))
    {
        for (int i = 0; i < 1000; i++)
        {
            w.WriteLine("Test");
        }
    }

This code however does not crash:

    using (var w = File.CreateText("file.txt"))
    {
        for (int i = 0; i < 1000; i++)
        {
            w.WriteLine("Test");
        }
    }

So, my guess can only be that the underlying native code treats text files differently than when you open the file using File.Create(). Both files are then written in UTF-8, so there is no difference about the encoding.

BTW: sorry I'm one year late on the answer, but I hope it'll help somebody


问:
How to align cards in carousel - Bootstrap 5?
I have simple Bootstrap 5 cards in carousel. When the card has less text the height on the card is getting smaller, and the carousel is jumping while sliding.

How can I stretch the cards to be the same height as the highest card, without using fixed values?

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

Basic Card 1

Basic card

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo
         eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna
         tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
         cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus
         dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae
         fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi,
         laoreet a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum
         consectetur. Vivamus venenatis hendrerit nulla quis vestibulum.

Basic Card 2

Basic card

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget
     congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a
     rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla cursus.
     Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam
     mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo
     nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet a felis ut,
     ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus
     venenatis hendrerit nulla quis vestibulum. In rhoncus purus sit amet urna luctus
     finibus. Nulla varius imperdiet sem, vel lacinia purus elementum id.

Basic Card 3

Basic card

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. .

  <button class="carousel-control-prev" type="button" data-bs-target="#demo" data-bs-slide="prev">

  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#demo" data-bs-slide="next">

  </button>

```</code>```

答:
I've created some CSS to adjust BS5 slider to make it work with slides, that have different height.

Also, I've updated card's structure according to BS5 docs:

card-title

card-text

I understand it's just example, but anyway, I did it just for better looking.

Take a look at comments I added to CSS part for more details.

/* updated carousel element to add gaps around cards */
.carousel {
  background-color: powderblue;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* make inner block flex to stretch slides */
.carousel-inner {
  display: flex;
}

/* make flex item to stretch parent container to max child height */
.carousel-item {
  display: flex !important;
  /* animate carousel item opacity property */
  opacity: 0;
  transition: transform .6s ease-in-out, opacity .3s ease-in-out !important;
}

/* animate carousel item opacity property */
.carousel-item.active {
  opacity: 1;
  z-index: 1;
}
.carousel-item-start,
.carousel-item-next {
  opacity: 1;
}
/* end of animating of opacity */

/* added for example purpose (make arrows darker) */
.carousel-control-prev-icon,
.carousel-control-next-icon {
  filter: brightness(0);
}

/* adjusting (stretching) slide's card to max height */
.carousel-item .container {
  display: flex;
  flex-direction: column;
}
.carousel-item .card {
  flex-grow: 1;
}
/* end of adjusting */

/* play around this classes to animate it like you want */
/*
.carousel-item-end
.carousel-item-next
.carousel-item-prev
.carousel-item-start
*/```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<div id="demo" class="carousel slide" data-bs-ride="carousel">
  <!-- The slideshow/carousel -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <div class="container mt-3">
        <h2>Basic Card 1</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
              cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
              a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="carousel-item">
      <div class="container mt-3">
        <h2>Basic Card 2</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
              cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
              a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum. In rhoncus purus sit amet urna luctus finibus. Nulla varius imperdiet sem, vel lacinia purus elementum
              id.
            </p>
          </div>
        </div>
      </div>
    </div>
    <div class="carousel-item">
      <div class="container mt-3">
        <h2>Basic Card 3</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. .</p>
          </div>
        </div>
      </div>
    </div>
  </div>

  <button class="carousel-control-prev" type="button" data-bs-target="#demo" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#demo" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div></code>```

Body:
I've created some CSS to adjust BS5 slider to make it work with slides, that have different height.

Also, I've updated card's structure according to BS5 docs:

card-title

card-text

I understand it's just example, but anyway, I did it just for better looking.

Take a look at comments I added to CSS part for more details.

/* updated carousel element to add gaps around cards */
.carousel {
  background-color: powderblue;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* make inner block flex to stretch slides */
.carousel-inner {
  display: flex;
}

/* make flex item to stretch parent container to max child height */
.carousel-item {
  display: flex !important;
  /* animate carousel item opacity property */
  opacity: 0;
  transition: transform .6s ease-in-out, opacity .3s ease-in-out !important;
}

/* animate carousel item opacity property */
.carousel-item.active {
  opacity: 1;
  z-index: 1;
}
.carousel-item-start,
.carousel-item-next {
  opacity: 1;
}
/* end of animating of opacity */

/* added for example purpose (make arrows darker) */
.carousel-control-prev-icon,
.carousel-control-next-icon {
  filter: brightness(0);
}

/* adjusting (stretching) slide's card to max height */
.carousel-item .container {
  display: flex;
  flex-direction: column;
}
.carousel-item .card {
  flex-grow: 1;
}
/* end of adjusting */

/* play around this classes to animate it like you want */
/*
.carousel-item-end
.carousel-item-next
.carousel-item-prev
.carousel-item-start
*/

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<div id="demo" class="carousel slide" data-bs-ride="carousel">
  <!-- The slideshow/carousel -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <div class="container mt-3">
        <h2>Basic Card 1</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
              cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
              a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="carousel-item">
      <div class="container mt-3">
        <h2>Basic Card 2</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
              cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
              a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum. In rhoncus purus sit amet urna luctus finibus. Nulla varius imperdiet sem, vel lacinia purus elementum
              id.
            </p>
          </div>
        </div>
      </div>
    </div>
    <div class="carousel-item">
      <div class="container mt-3">
        <h2>Basic Card 3</h2>
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Basic card</h5>
            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. .</p>
          </div>
        </div>
      </div>
    </div>
  </div>

  <button class="carousel-control-prev" type="button" data-bs-target="#demo" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#demo" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>


问:
Simple operation to waste time?
I'm looking for a simple operation / routine which can "waste" time if repeated continuously.

I'm researching how gprof profiles applications, so this "time waster" needs to waste time in the user space and should not require external libraries. IE, calling sleep(20) will "waste" 20 seconds of time, but gprof will not record this time because it occurred within another library.

Any recommendations for simple tasks which can be repeated to waste time?

答:
A simple loop would do.
If you're researching how gprof works, I assume you've read the paper, slowly and carefully.
I also assume you're familiar with these issues.</p>

Title: Simple operation to waste time?