草庐IT

Tomcat-Spring-Hibernate

全部标签

java - Spring Boot 应用程序在启动时终止

我正在尝试一个简单的springboot应用程序,它总是自动关闭::SpringBoot::(v1.4.1.RELEASE)2016-10-2313:05:21.681INFO16532---[main]com.example.RestBootApplication:Noactiveprofileset,fallingbacktodefaultprofiles:default2016-10-2313:05:21.766INFO16532---[main]s.c.a.AnnotationConfigApplicationContext:Refreshingorg.springframew

java - 带有 Spring Boot REST 应用程序的 OAuth2 - 无法使用 token 访问资源

我想为我的RESTspringboot项目使用OAuth2。使用一些示例,我为OAuth2创建了配置:@ConfigurationpublicclassOAuth2Configuration{privatestaticfinalStringRESOURCE_ID="restservice";@Configuration@EnableResourceServerprotectedstaticclassResourceServerConfigurationextendsResourceServerConfigurerAdapter{@Overridepublicvoidconfigure(

java - 在 Spring Boot 中为 @WebMvcTest 禁用 Spring Security 配置类

最近我使用以下类将SpringSecurity添加到我的SpringBoot项目中:@EnableWebSecurity@EnableGlobalMethodSecurity(prePostEnabled=true)publicclassMySecurityConfig{}因此,默认情况下,我的所有URL现在都受到身份验证和自行生成的密码的保护。问题是我用于对Controller进行单元测试的@WebMvcTest类中的所有测试:@RunWith(SpringRunner.class)@WebMvcTest(SomeController.class)publicclassSomeCon

java - Hibernate映射文件和注解的区别

今天我尝试创建一个使用Hibernate作为ORM的应用程序。所以在创作的时候我有一个疑问。使用Hibernate映射文件(.hbm文件)或注释的最佳做法是什么?它的优点和缺点是什么?请帮助我理解。 最佳答案 没有功能上的区别。您可以用这两种方法做(几乎)相同的事情xml文件是在Java有注解(1.5中添加)之前使用的,因此它们可以被认为是一种过时的映射方式通常首选使用JPA注释而不是特定于hibernate的注释;如果使用xml-有一种JPAxml格式,应该优先于hibernatenative格式

java - 如何使用 spring java 配置在单例 bean 中生成原型(prototype)对象

这是我现在拥有的,效果很好。它所做的只是一个市场类,它返回一个项目对象数组:我有类(class)市场classmarket{publicArrayListcreateItems(HashMapmap){ArrayListarray=newArrayList();for(Map.Entrym:map.entrySet()){Itemitem=newItem();item.setName(m.key());item.setValue(m.value());array.add(item);}returnarray;}}类Item是一个简单的类,带有用于名称和值的getter和setter这是

java - 如何将@RequestParam 绑定(bind)到spring MVC 中的对象?

我想通过AJAX发出POST请求,我还想将整个类对象绑定(bind)到该请求,我想接收带有@requestParam注释的请求。我知道可以使用@requestBody注释来完成,但我很想知道:我们可以使用@requestParam注释来完成吗?Ajax代码:varrestDTO{id:3,name:"hello"}$.ajax({url:url,type:'POST',dataType:'json',contentType:'application/json',mimeType:'application/json',data:JSON.stringify({RestDTO:restDT

java - Spring LDAP 基本用法

我试图通过设置最基本的工作程序来弄清楚SpringLDAP(不是Spring安全性东西)是如何工作的,但似乎实际的身份验证中断了。这是我得到的错误:Exceptioninthread"main"java.lang.NullPointerExceptionatorg.springframework.ldap.core.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:125)atorg.springframework.ldap.core.LdapTemplate.search(LdapT

java - 表达式语言跳过 tomcat 7 中的标识符检查

我收到以下错误:SEVERE:Servlet.service()forservletjspthrewexceptionjavax.el.ELException:Theidentifier[case]isnotavalidJavaidentifierasrequiredbysection1.19oftheELspecification(Identifier::=Javalanguageidentifier).Thischeckcanbedisabledbysettingthesystempropertyorg.apache.el.parser.SKIP_IDENTIFIER_CHECKt

java - NetBeans 7.0.1 : Access to Tomcat server has not been authorized

我是初学者,刚开始使用JSP并且卡在了起点。请帮帮我。我已经下载catalina.bat和setclasspath.bat在适当的位置/tomcat/bin/但仍然出现授权错误。我看过类似的帖子并编辑了我的tomcat-users.xml用这条线但仍然无法成功运行它。Seetheserverlogfordetails.atorg.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:232)atorg.netbeans.modules.j2ee.ant.Deploy.execu

java - 没有可用的事务性 EntityManager - 使用 JPA Api,Hibernate Session 出错

我正在尝试从注入(inject)的EntityManager中解包HibernateSession,因为我需要使用Hibernate的nativeCriteriaAPI。当我尝试使用Criteria时出现以下异常:Causedby:java.lang.IllegalStateException:NotransactionalEntityManageravailableatorg.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEnti