我遇到过很多关于java SpringMVC项目配置文件的教程,并且通常在他们的类名中有@Configuration,但是他们从未提到过准确放置这些文件的位置。
例如,我了解到我可以通过扩展RepositoryRestMvcConfiguration来更改Spring Data Rest rest api。
1)我希望能够为存储库提供更长的网址,因此我可以拥有api / amazon /产品而不是api / amazonproducts。显然这是不可能的。我最终拥有;
@RepositoryRestResource(collectionResourceRel = "amazonproducts", path = "amazonproducts")
@CrossOrigin
public interface AmazonProductRepository extends PagingAndSortingRepository<AmazonProduct, Long> {
我所要做的就是创建类似的;
class CustomRestMvcConfiguration extends RepositoryRestMvcConfiguration {
@Override
@Bean
public HateoasPageableHandlerMethodArgumentResolver pageableResolver() {
HateoasPageableHandlerMethodArgumentResolver resolver = super.pageableResolver();
resolver.setOneIndexedParameters(true);
return resolver;
}
}
我不知道放置此代码的文件/文件夹。我正在使用Eclipse Java EE Oxygen。我创建了一个maven项目,我目前正在spring-boot上测试它
答案 0 :(得分:2)
只要程序包包含在组件扫描中,您就可以在所需的任何程序包中放置<html>
<head>
<link rel="stylesheet" type="text/css" href="css/1.css">
</head>
<body>
<div style="border: 1px solid orange; padding: 1px">
<span>level1</span>
<div style="border: 1px solid blue; padding: 1px">
<span>level2</span>
<div style="border: 1px solid green; padding: 1px">
<span>level3</span>
<div class="respon">
<table>
<tbody>
<tr>
<td>1</td>
<td><input value="2017-01-01" type="text"></td>
<td><input value="abc" type="text"></td>
<td><input value="3" type="text"></td>
<td><select>
<option value="">Select</option>
<option>abc</option>
<option>def</option>
<option>ghi</option>
</select></td>
<td><input value="10" type="text"></td>
<td><input value="" type="text"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
带注释的类。
在Spring Boot中,默认情况下,它与包含@SpringBootApplication
或任何子包的类在同一个包中,与Spring管理的所有其他类相同。
除此之外,Spring并不关心软件包名称。