我正在使用Spring(Boot)构建REST Web服务,并尝试使用hibernate作为orm mapper而不使用任何xml配置.
我基本上可以使用它,但我遇到了配置问题.我实例LocalContainerEntityManagerFactoryBean作为@Bean一个@Configuration文件.
我hibernate.ejb.naming_strategy在下面的例子中设置 - >这似乎适用于创建表,如果它们不存在(列名是像我的@Entity类中的camelCase)但是当执行查询时,hibernate"忘记"关于这个命名配置和尝试使用另一种命名策略与under_score_attributes - >显然这些查询失败.我需要设置其他任何属性吗?
或者另一种配置属性的方法,最好不要添加cfg.xml或者persistence.xml?
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
Properties props = new Properties();
props.put("hibernate.hbm2ddl.auto", "create");
props.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.DefaultNamingStrategy");
lef.setJpaProperties(props);
lef.afterPropertiesSet();
Run Code Online (Sandbox Code Playgroud) 我有两列的excel表:日期(dd / mm / yyy hh:mm)和值(整数)。
该表在4天的时间范围内大约有8000个值。
当我尝试在这两列上创建折线图或条形图时,excel会以某种方式累计一天的所有值(忽略时间)。即我得到一个带有4条柱形图的条形图。
我真正想要的是条形图/折线图,其中每一行都类似于折线图中的条形图/点。在哪里可以找到friggin选项来告诉Excel我想要什么?
信息:我使用Mac的MS Excel:2011,但是我很确定这不是版本相关的问题,而是第8层问题;)
我正在开发基于Spring boot的webservice,其结构如下:
控制器(REST) - >服务 - >存储库(如某些教程中所建议的).
我的数据库连接(JPA/Hibernate/MySQL)在@Configuration类中定义.(见下文)
现在我想为我的Service类中的方法编写简单的测试,但我真的不明白如何将ApplicationContext加载到我的测试类中以及如何模拟JPA/Repositories.
这是我走了多远:
我的服务类
@Component
public class SessionService {
@Autowired
private SessionRepository sessionRepository;
public void MethodIWantToTest(int i){
};
[...]
}
Run Code Online (Sandbox Code Playgroud)
我的考试班:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
public class SessionServiceTest {
@Configuration
static class ContextConfiguration {
@Bean
public SessionService sessionService() {
return new SessionService();
}
}
@Autowired
SessionService sessionService;
@Test
public void testMethod(){
[...]
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到以下例外:
引起:org.springframework.beans.factory.BeanCreationException:创建名为'sessionService'的bean时出错:注入自动连接的依赖项失败; 嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private com.myApp.SessionRepository com.myApp.SessionService.sessionRepository; 嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到[com.myApp.SessionRepository]类型的限定bean用于依赖:预期至少有1个bean符合此依赖关系的autowire候选者.依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}
为了完整性:这是我的@Configuration for jpa:
@Configuration
@EnableJpaRepositories(basePackages={"com.myApp.repositories"})
@EnableTransactionManagement
public class JpaConfig { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用org.apache.http.entity.mime.MultipartEntityBuilder在multipart/form-data POST请求上模仿我的浏览器行为
我的浏览器只发送Content-Disposition,但没有Content-Type或Content-Transfer-Encoding Headers.我尝试使用MultipartEntityBuilder.addPart()和addTextBody(),但默认情况下都添加了这些Headers:
我想要的(我的Chrome浏览器的功能):
POST .../some.jsp HTTP/1.1
Host: ...
Connection: keep-alive
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary6tcnkxC7txvqE5Xl
------WebKitFormBoundary6tcnkxC7txvqE5Xl
Content-Disposition: form-data; name="merkmal"
5
Run Code Online (Sandbox Code Playgroud)
我从MultipartEntityBuilder得到了什么
POST.../some.jsp HTTP/1.1
Host: ...
Content-Type: multipart/form-data; boundary=m9Zb2QD-QaH-j-HqgGQfI8KwDkToz17ULYkZ
--m9Zb2QD-QaH-j-HqgGQfI8KwDkToz17ULYkZ
Content-Disposition: form-data; name="merkmal"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
5
Run Code Online (Sandbox Code Playgroud)
为什么?:指定的服务器认为name ="merkmal"之后的所有内容都是merkmal(包括Headers)的值.其他可能的原因:整个请求可能有某种错误的编码(特别是换行)?
ByteIterableXodus中的密钥和/或值是否有最大长度?如果存在硬限制,那么限制是多少(即多少字节)?如果ByteIterable超过这个限制会发生什么?
假设我的公司有很多模式,一些用于web服务,一些用于其他目的.通过导入以及应用程序特定的模式,在许多这些模式中使用了常见的类型定义.
现在,然后更改,版本化和导出模式.
到目前为止,该公司使用SVN来存储架构文件.它们没有高效的结构,存在冗余和其他问题.文件和文件夹没有明确的层次结构.
问题1:使用SVN存储和版本XSD文件是一个好习惯.什么是另一种好方法?
问题2:我怎么能有效地构建文件?我想将它们组织在关联文件命名空间的文件夹中.
问题3:导出时,更常见的是给出一个flattend副本(一个包含所有文件的文件夹)或根据命名空间保持文件夹hirarchy?