play-spring-jpa 连接数据库出错

persistence.xml中配置

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="default" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>DefaultDS</jta-data-source>  
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="update"/>

    </properties>
</persistence-unit>

报错内容

play.api.UnexpectedException: Unexpected exception[UnsatisfiedDependencyExceptio
n: Error creating bean with name 'application' defined in file [D:\play-spring-d
ata-jpa\target\scala-2.10\classes\controllers\Application.class]: Unsatisfied de
pendency expressed through constructor argument with index 0 of type [models.Per
sonRepository]: : Error creating bean with name 'personRepository': Cannot creat
e inner bean '(inner bean)' of type [org.springframework.orm.jpa.SharedEntityMan
agerCreator] while setting bean property 'entityManager'; nested exception is or
g.springframework.beans.factory.BeanCreationException: Error creating bean with
name '(inner bean)#1': Cannot resolve reference to bean 'entityManagerFactory' w
hile setting constructor argument; nested exception is org.springframework.beans
.factory.BeanCreationException: Error creating bean with name 'entityManagerFact
ory' defined in class Global$SpringDataJpaConfiguration: Instantiation of bean f
ailed; nested exception is org.springframework.beans.factory.BeanDefinitionStore
Exception: Factory method [public javax.persistence.EntityManagerFactory Global$
SpringDataJpaConfiguration.entityManagerFactory()] threw exception; nested excep
tion is javax.persistence.PersistenceException: [PersistenceUnit: default] Unabl
e to build EntityManagerFactory; nested exception is org.springframework.beans.f
actory.BeanCreationException: Error creating bean with name 'personRepository':
Cannot create inner bean '(inner bean)' of type [org.springframework.orm.jpa.Sha
redEntityManagerCreator] while setting bean property 'entityManager'; nested exc
eption is org.springframework.beans.factory.BeanCreationException: Error creatin
g bean with name '(inner bean)#1': Cannot resolve reference to bean 'entityManag
erFactory' while setting constructor argument; nested exception is org.springfra
mework.beans.factory.BeanCreationException: Error creating bean with name 'entit
yManagerFactory' defined in class Global$SpringDataJpaConfiguration: Instantiati
on of bean failed; nested exception is org.springframework.beans.factory.BeanDef
initionStoreException: Factory method [public javax.persistence.EntityManagerFac
tory Global$SpringDataJpaConfiguration.entityManagerFactory()] threw exception;
nested exception is javax.persistence.PersistenceException: [PersistenceUnit: de
fault] Unable to build EntityManagerFactory]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anon
fun$1.apply(ApplicationProvider.scala:148) ~[play_2.10.jar:2.2.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anon
fun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.3]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply
(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply
(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.3]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Err
or creating bean with name 'application' defined in file [D:\play-spring-data-jp
a\target\scala-2.10\classes\controllers\Application.class]: Unsatisfied dependen
cy expressed through constructor argument with index 0 of type [models.PersonRep
ository]: : Error creating bean with name 'personRepository': Cannot create inne
r bean '(inner bean)' of type [org.springframework.orm.jpa.SharedEntityManagerCr
eator] while setting bean property 'entityManager'; nested exception is org.spri
ngframework.beans.factory.BeanCreationException: Error creating bean with name '
(inner bean)#1': Cannot resolve reference to bean 'entityManagerFactory' while s
etting constructor argument; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Error creating bean with name 'entityManagerFactory' d
efined in class Global$SpringDataJpaConfiguration: Instantiation of bean failed;
nested exception is org.springframework.beans.factory.BeanDefinitionStoreExcept
ion: Factory method [public javax.persistence.EntityManagerFactory Global$Spring
DataJpaConfiguration.entityManagerFactory()] threw exception; nested exception i
s javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to b
uild EntityManagerFactory; nested exception is org.springframework.beans.factory
.BeanCreationException: Error creating bean with name 'personRepository': Cannot
create inner bean '(inner bean)' of type [org.springframework.orm.jpa.SharedEnt
ityManagerCreator] while setting bean property 'entityManager'; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name '(inner bean)#1': Cannot resolve reference to bean 'entityManagerFact
ory' while setting constructor argument; nested exception is org.springframework
.beans.factory.BeanCreationException: Error creating bean with name 'entityManag
erFactory' defined in class Global$SpringDataJpaConfiguration: Instantiation of
bean failed; nested exception is org.springframework.beans.factory.BeanDefinitio
nStoreException: Factory method [public javax.persistence.EntityManagerFactory G
lobal$SpringDataJpaConfiguration.entityManagerFactory()] threw exception; nested
exception is javax.persistence.PersistenceException: [PersistenceUnit: default]
Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.ConstructorResolver.createA
rgumentArray(ConstructorResolver.java:730) ~[spring-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowir
eConstructor(ConstructorResolver.java:196) ~[spring-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045) ~[spri
ng-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949) ~[spring
-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) ~[spring-beans
.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans.j
ar:3.2.3.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'personRepository': Cannot create inner bean '(inner bean)' of
type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bea
n property 'entityManager'; nested exception is org.springframework.beans.factor
y.BeanCreationException: Error creating bean with name '(inner bean)#1': Cannot
resolve reference to bean 'entityManagerFactory' while setting constructor argum
ent; nested exception is org.springframework.beans.factory.BeanCreationException
: Error creating bean with name 'entityManagerFactory' defined in class Global$S
pringDataJpaConfiguration: Instantiation of bean failed; nested exception is org
.springframework.beans.factory.BeanDefinitionStoreException: Factory method [pub
lic javax.persistence.EntityManagerFactory Global$SpringDataJpaConfiguration.ent
ityManagerFactory()] threw exception; nested exception is javax.persistence.Pers
istenceException: [PersistenceUnit: default] Unable to build EntityManagerFactor
y
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveInnerBean(BeanDefinitionValueResolver.java:282) ~[spring-beans.jar:3.2.3
.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:126) ~[spring-beans.ja
r:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387) ~[spri
ng-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) ~[spring-bean
s.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans
.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans.j
ar:3.2.3.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name '(inner bean)#1': Cannot resolve reference to bean 'entityMana
gerFactory' while setting constructor argument; nested exception is org.springfr
amework.beans.factory.BeanCreationException: Error creating bean with name 'enti
tyManagerFactory' defined in class Global$SpringDataJpaConfiguration: Instantiat
ion of bean failed; nested exception is org.springframework.beans.factory.BeanDe
finitionStoreException: Factory method [public javax.persistence.EntityManagerFa
ctory Global$SpringDataJpaConfiguration.entityManagerFactory()] threw exception;
nested exception is javax.persistence.PersistenceException: [PersistenceUnit: d
efault] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveReference(BeanDefinitionValueResolver.java:329) ~[spring-beans.jar:3.2.3
.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107) ~[spring-beans.ja
r:3.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolve
ConstructorArguments(ConstructorResolver.java:615) ~[spring-beans.jar:3.2.3.RELE
ASE]
at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:441) ~[spring-beans.jar:3.2.3.RE
LEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:10
25) ~[spring-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921) ~[spring
-beans.jar:3.2.3.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'entityManagerFactory' defined in class Global$SpringDataJpaCo
nfiguration: Instantiation of bean failed; nested exception is org.springframewo
rk.beans.factory.BeanDefinitionStoreException: Factory method [public javax.pers
istence.EntityManagerFactory Global$SpringDataJpaConfiguration.entityManagerFact
ory()] threw exception; nested exception is javax.persistence.PersistenceExcepti
on: [PersistenceUnit: default] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:581) ~[spring-beans.jar:3.2.3.RE
LEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:10
25) ~[spring-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921) ~[spring
-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) ~[spring-beans
.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans.j
ar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:295) ~[spring-beans.jar:3.2.3.RELEASE]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Facto
ry method [public javax.persistence.EntityManagerFactory Global$SpringDataJpaCon
figuration.entityManagerFactory()] threw exception; nested exception is javax.pe
rsistence.PersistenceException: [PersistenceUnit: default] Unable to build Entit
yManagerFactory
at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:181) ~[spring-beans.jar:3.2.3.RELE
ASE]
at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:570) ~[spring-beans.jar:3.2.3.RE
LEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:10
25) ~[spring-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921) ~[spring
-beans.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) ~[spring-beans
.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans.j
ar:3.2.3.RELEASE]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Un
able to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:915) ~[hibernate-entitymanager-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(Hib
ernatePersistence.java:57) ~[hibernate-entitymanager-3.6.10.Final.jar:3.6.10.Fin
al]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:63) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:47) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]
at Global$SpringDataJpaConfiguration.entityManagerFactory(Global.java:76
) ~[na:na]
at Global$SpringDataJpaConfiguration$$EnhancerByCGLIB$$715a97cd.CGLIB$en
tityManagerFactory$0() ~[na:na]
Caused by: org.hibernate.HibernateException: The chosen transaction strategy req
uires access to the JTA TransactionManager
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:
390) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1872) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:906) ~[hibernate-entitymanager-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(Hib
ernatePersistence.java:57) ~[hibernate-entitymanager-3.6.10.Final.jar:3.6.10.Fin
al]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:63) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:47) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Spring Boot 使用JPA连接MySQL数据库报错 is not mapped
小白向各位大侠求助: 创建Spring Boot 工程时,使用JPA连接MySQL数据库,查询时报错,报错信息如下: ``` 2018-06-04 06:34:44.959 ERROR 6116 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.ast.QuerySyntaxException: Person is not mapped [select t from Person t]; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Person is not mapped [select t from Person t]] with root cause org.hibernate.hql.internal.ast.QuerySyntaxException: Person is not mapped at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:169) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:79) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:326) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3706) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3595) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:576) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:266) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:553) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:662) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE] at com.sun.proxy.$Proxy76.createQuery(Unknown Source) ~[na:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:304) ~[spring-orm-5.0.6.RELEASE.jar:5.0.6.RELEASE] at com.sun.proxy.$Proxy76.createQuery(Unknown Source) ~[na:na] at com.neuqsoft.demo.repository.impl.PersonDaoImpl.findAll(PersonDaoImpl.java:52) ~[classes/:na] at com.neuqsoft.demo.repository.impl.PersonDaoImpl$$FastClassBySpringCGLIB$$7895840c.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE] at com.neuqsoft.demo.repository.impl.PersonDaoImpl$$EnhancerBySpringCGLIB$$182f86eb.findAll(<generated>) ~[classes/:na] at com.neuqsoft.demo.service.PersonService.findAll(PersonService.java:50) ~[classes/:na] at com.neuqsoft.demo.controller.PersonController.getPseronList(PersonController.java:59) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) ~[spring-webmvc-5.0.6.RELEASE.jar:5.0.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) [tomcat-embed-core-8.5.31.jar:8.5.31] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.31.jar:8.5.31] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.31.jar:8.5.31] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131] ``` 实体文件: ``` @Entity @Table(name = "person") public class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) private String id; @Column(name="name") private String name; @Column(name="sex") private String sex; @Column(name="tel") private String tel; @Column(name="address") private String address; @Column(name="age") private String age; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getTel() { return tel; } public void setTel(String tel) { this.tel = tel; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } } ``` 数据库表: ![图片说明](https://img-ask.csdn.net/upload/201806/04/1528064584_339931.jpg) DAO文件: ``` package com.neuqsoft.demo.repository.impl; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import com.neuqsoft.demo.entity.Person; import com.neuqsoft.demo.repository.PersonDao; @Repository public class PersonDaoImpl implements PersonDao { @Autowired @PersistenceContext private EntityManager entityManager; @Override public List<Person> findAll() { return this.entityManager.createQuery("select t from Person t").getResultList(); } } ``` 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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.neuqsoft</groupId> <artifactId>DemoJPAForSpringBoot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>DemoJPAForSpringBoot</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- custom renw --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ``` application.properties: ``` #mysql #datasource spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/forspringboot?useSSL=false spring.datasource.username=root spring.datasource.password=1qaz!QAZ spring.jpa.show-sql= true ```
jpa通过连接池连接数据库 怎样算是一次连接
在使用jpa操作mysql数据库时 <br> jpa通过连接池连接数据库 怎样算是一次连接? 连接什么时候结束?
spring-data-jpa事务不起作用
spring-data-jpa中的repository事务没有问题,但是在Service中添加Transactional注解事务就不起作用, 中间有异常不能回滚,spring的配置如下 ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <!-- 指定数据源 --> <property name="dataSource" ref="dataSource"/> <!-- 指定Jpa持久化实现厂商类,这里以Hibernate为例 --> <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/> <property name="packagesToScan" value="com.test.domain"/> <property name="jpaProperties"> <props> <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <prop key="javax.persistence.validation.mode">none</prop> <prop key="hibernate.use_sql_comments">false</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.max_fetch_depth">1</prop> <!-- 二级缓存设置 --> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop> <prop key="hibernate.cache.use_query_cache">true</prop> </props> </property> <property name="sharedCacheMode" value="ENABLE_SELECTIVE"/> </bean> <!-- Hibernate对Jpa的实现 --> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> <!-- 数据源配置,使用应用内的DBCP数据库连接池 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${db.driverClass}"/> <property name="url" value="${db.jdbcUrl}"/> <property name="username" value="${db.user}"/> <property name="password" value="${db.password}"/> <!-- 配置初始化大小、最小、最大 --> <property name="initialSize" value="${db.initialSize}"/> <property name="minIdle" value="${db.minIdle}"/> <property name="maxActive" value="${db.maxActive}"/> <!-- 配置获取连接等待超时的时间 --> <property name="maxWait" value="${db.maxWait}"/> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name="timeBetweenEvictionRunsMillis" value="${db.timeBetweenEvictionRunsMillis}"/> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name="minEvictableIdleTimeMillis" value="${db.minEvictableIdleTimeMillis}"/> <property name="testWhileIdle" value="true"/> <property name="testOnBorrow" value="false"/> <property name="testOnReturn" value="false"/> <!-- 打开PSCache,并且指定每个连接上PSCache的大小 --> <property name="poolPreparedStatements" value="${db.poolPreparedStatements}"/> <property name="maxPoolPreparedStatementPerConnectionSize" value="${db.maxPoolPreparedStatementPerConnectionSize}"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <jpa:repositories base-package="com.test.dao.reposities.db" entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager" /> </beans> ``` ``` <!-- 组件自动扫描 (注解) --> <context:component-scan base-package="com.test"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/> </context:component-scan> <!-- 开启注解事务 --> <!-- 使用 JDK 动态代理: proxy-target-class="false" @Transactional可以标注在接口或者父类上 使用CGLIB动态代理: proxy-target-class="true" @Transactional不能标注在接口或者父类上,需要标注在业务实现类或是其方法上,否则事务不生效 --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> ``` 请大神们给解答一些为什么在Service中配置事务不起作用?
spring boot,spring data jpa同一事务内修改不可见
目前我遇到这么个问题,在同一事务内,先saveAndFlush()了一条数据,在同一方法内,事务最终提交前,然后立刻查询此数据,但是并查不到。但是据我多年经验,同一事务内,尽管没提交,但是其修改在同一的当前的事务内应该是可见的才对呀。 困惑很久了,什么各种事务隔离性都试了,况且所谓事务隔离性,都是指不同事务间,我这是同一事务内都不可见,求求大侠们帮忙看看, 实在找不到解决思路了。谢谢大家,哎,没有C币,只能乞求大家了。 详细的代码和过程,我已经发在stackoverflow了,链接如下: [https://stackoverflow.com/questions/53449779/the-modifying-can-not-be-visible-in-the-same-transaction-in-spring-data-jpa-why/53455542#53455542](https://stackoverflow.com/questions/53449779/the-modifying-can-not-be-visible-in-the-same-transaction-in-spring-data-jpa-why/53455542#53455542 "")。
spring boot + jpa访问数据库时报这个错,调用CrudRepository保存的时候
java.lang.NullPointerException: null at com.yd.cn.controller.SampleController.hello(SampleController.java:26) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:237) ~[spring-boot-actuator-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:112) ~[spring-boot-actuator-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103) ~[spring-boot-actuator-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[catalina.jar:8.5.11] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[catalina.jar:8.5.11] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[catalina.jar:8.5.11] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.11] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [catalina.jar:8.5.11] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.11] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.5.11] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.11] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [catalina.jar:8.5.11] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-coyote.jar:8.5.11] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.11] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-coyote.jar:8.5.11] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-coyote.jar:8.5.11] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.11] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.11] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102] ![图片说明](https://img-ask.csdn.net/upload/201708/22/1503380371_349769.png)![![图片说明](https://img-ask.csdn.net/upload/201708/22/1503380520_871584.png)图片说明](https://img-ask.csdn.net/upload/201708/22/1503380462_232925.png)
Spring Data jpa+Mongodb查询全部数据出错
代码: List<Comment> comments = commentDao.findAll(); findAll为继承自MongoRepository的方法 报错: Caused by: com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "comment" }' on server localhost:27017 at com.mongodb.operation.FindOperation$1.call(FindOperation.java:735) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:725) at com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463) at com.mongodb.operation.FindOperation.execute(FindOperation.java:725) at com.mongodb.operation.FindOperation.execute(FindOperation.java:89) at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:189) at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:143) at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2793) ... 86 more 试过换工程、换数据库、换表、换版本,依旧没有解决,而且几乎搜不到这个错误。
spring-data-jpa delete
现在使用spring-data-jpa为什么运行下面的代码courseDetai没有被删除呢? [code="java"]@Transactional(readOnly = false) public void deleteCourseDetail(Long id, Long courseId) { Course course = courseDao.findOne(courseId); CourseDetail courseDetail = courseDetailDao.findOne(id); System.out.println(course.getCourseDetails().size()); course.getCourseDetails().remove(courseDetail); System.out.println("after: " + course.getCourseDetails().size()); courseDao.save(course); } @OneToMany(mappedBy = "course", fetch = FetchType.LAZY, cascade = {CascadeType.ALL}) public List<CourseDetail> getCourseDetails() { return courseDetails; }[/code]
spring data jpa 第一行代码我save了某一个表的数据,看到数据库数据变了。
spring data jpa 第一行代码我save了某一个表的数据,看到数据库数据变了。 我第二行去查询这个表的数据,得到的却是没保存数据之前的数据。 再刷新页面就得到了现在数据库的数据是咋回事呢
dubbo spring boot spring-data-jpa报错
当有多个service实现类注入同一个Repository时,就报下面的错: ``` Caused by: java.lang.IllegalArgumentException: Repository interface must not be null on initialization! at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:213) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:50) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] ... 255 common frames omitted ``` 1、可以正常启动的情况 ``` @Service(version = "1.0.0") public class EmployeeAccountServiceImpl implements EmployeeAccountService { @Autowired EmployeeRepository employeeRepository; ``` 2、不能正常启动的情况 ``` @Service(value = "employeeAccountService") //@Service(version = "1.0.0") public class EmployeeAccountServiceImpl implements EmployeeAccountService { @Autowired EmployeeRepository employeeRepository; ``` ``` <dubbo:service interface="com.xxx.service.employee.EmployeeAccountService" ref="employeeAccountService" version="1.0.0" validation="true"/> ```
spring jpa hibernate性能问题
使用spring jpa hibernate向mysql数据库中存储数据,发现插入一条数据耗时几十毫秒到几百毫秒,如何能够提高save性能,时间缩短至10毫秒以下。
maven同时导入spring-boot-devtools和spring-boot-starter-data-jpa无法启动
springboot同时导入两个包启动时会报错,删掉一个就可以启动了。 错误信息如下 Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/zyh/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:132) at org.springframework.boot.devtools.restart.ChangeableUrls.fromClassLoader(ChangeableUrls.java:98) at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:92) at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56) at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:142) at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:556) at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:76) at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:50) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69) at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48) at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) at com.example.demoshiro.DemoshiroApplication.main(DemoshiroApplication.java:11) Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(ZipFile.java:60) at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) at sun.misc.IOUtils.readFully(IOUtils.java:65) at java.util.jar.JarFile.getBytes(JarFile.java:425) at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193) at java.util.jar.JarFile.getManifest(JarFile.java:180) at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromManifestClassPathAttribute(ChangeableUrls.java:153) at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:129) ... 17 more
使用 spring data jpa
使用spring data jpa 报错Page 1 of 0 containing UNKNOWN instances 如果是 自己添加数据可以查询出来 而数据库以前存在的数据查询不到 大神救急!!!
spring data jpa 自动生成数据库表的主键数据怎么定义成varchar类型
@Entity @Table(name = "contract") public class Contract implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="contractNo",nullable=false,length=512) private String contractNo; @Column(name = "contract_year") private String contractYear; } 当我的contractNo定义成String类型是创建表数据的时候会报错,定义成int、Long、Integer类型就不会,要怎么设置才能创建varchar类型的数据表数据
Spring data jpa ExampleMatcher
spring data jpa如何用ExampleMatcher写一个不等于查询条件
mybatis和jpa都是需要实体操作数据库的吗?
现在需要写个系统,但是公司要求用存储过程,直接拿参数请求存储过程 hibernate可以实现 mybatis和jpa可以吗? 还有一个问题是,数据库表正在使用,直接添加表的字段会不会对程序造成影响?
springmvc spring hibernate 怎么配置连接两个数据库
persistent.xml配置 ``` <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="userPU" transaction-type="RESOURCE_LOCAL"> <!--jpa的提供者--> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <!--声明数据库连接的驱动--> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <!--jdbc数据库的连接地址--> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/manager?characterEncoding=gbk"/> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="123456"/> <!--配置方言--> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <!--激活查询日志功能--> <property name="hibernate.show_sql" value="true"/> <!--优雅地输出Sql--> <property name="hibernate.format_sql" value="true"/> <!--添加一条解释型标注--> <property name="hibernate.use_sql_comments" value="false"/> <!--配置如何根据java模型生成数据库表结构,常用update,validate--> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence> ``` applicationContext.xml配置 ``` <!--第二步--> <!--定义实体的工厂bean--> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="userPU" /> <property name="persistenceXmlLocation" value="classpath:persistence.xml"></property> </bean> <!--第三步--> <!--定义事务管理器--> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> ``` 以上是连接MySql的配置,现在我想在连接SqlServer,应该怎么配置,在写一个persistent和applicationContext?
spring+springmvc+springdata+jpa框架怎么连接两个不同的数据库
一个是本地mysql数据库,一个是orcale数据库 有没有demo看一下
spring data jpa怎么配置?
spring data jpa怎么配置? spring data jpa怎么配置? spring data jpa怎么配置? spring data jpa怎么配置?
求spring mvc +jpa配置
求spring mvc +jpa配置
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
使用 Docker 部署 Spring Boot 项目
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下。首先构建一个简单的 S...
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
redis分布式锁,面试官请随便问,我都会
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
为什么要学数据结构?
一、前言 在可视化化程序设计的今天,借助于集成开发环境可以很快地生成程序,程序设计不再是计算机专业人员的专利。很多人认为,只要掌握几种开发工具就可以成为编程高手,其实,这是一种误解。要想成为一个专业的开发人员,至少需要以下三个条件: 1) 能够熟练地选择和设计各种数据结构和算法 2) 至少要能够熟练地掌握一门程序设计语言 3) 熟知所涉及的相关应用领域的知识 其中,后两个条件比较容易实现,而第一个...
Android 9.0 init 启动流程
阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:一、启动流程概述一、 启动流程概述Android启动流程跟Linux启动类似,大致分为如下五个阶段。1.开机上电,加载固化的ROM。2.加载BootLoader,拉起Android OS。3.加载Uboot,初始外设,引导Kernel启动等。...
相关热词 基于c#波形控件 c# 十进制转十六进制 对文件aes加密vc# c#读取栈中所有的值 c# rsa256加密 好 学c# 还是c++ c# 和java的差距 c# curl网络框架 c# https证书请求 c# 中崎
立即提问