我有一个简单的Spring,基于Gradle的Web服务项目,其中包含以下内容 结构:
<link href="https://cdn.jsdelivr.net/npm/foundation-sites@6.4.3/dist/css/foundation.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="categoryfilter" id="association" data-tableId="card-parent">
<option>Association</option>
<option>Kent</option>
<option>Wales</option>
<option>Stafford</option>
</select>
<select name="categoryfilter" id="discipline" data-tableId="card-parent">>
<option>Discipline</option>
<option>Discipline Choice 1</option>
<option>Discipline Choice 2</option>
<option>Discipline Choice 3</option>
</select>
<div class="card-parent">
<h1 class="bio-card-title">
John & Peanuts </h1>
<div class="small-12 column biography-card-text">
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's name: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Peanuts </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Breed: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Pitbull </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's age: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
10 </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Handler: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
John </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Association: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Stafford </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Discipline: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Discipline Choice 1 </p>
</div>
</div>
<div class="column bio-card-btm-content">
<p>Example text</p>
<div style="clear:both;"></div>
</div>
</div>
</div>
<div class="card-parent">
<h1 class="bio-card-title">
Alex & Ben </h1>
<div class="small-12 column biography-card-text">
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's name: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Ben </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Breed: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Labrador </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's age: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
12 </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Handler: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Alex </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Association: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Kent </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Discipline: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Discipline Choice 2 </p>
</div>
</div>
<div class="column bio-card-btm-content">
<p>Example text</p>
<div style="clear:both;"></div>
</div>
</div>
</div>
<div class="card-parent">
<h1 class="bio-card-title">
Kyle & Nougat </h1>
<div class="small-12 column biography-card-text">
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's name: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Nougat </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Breed: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Hound </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Dog's age: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
7 </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Handler: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Kyle </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Association: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Wales </p>
</div>
</div>
<div class="row bio-card-row">
<div class="small-5 column">
<p class="bio-field-title">
Discipline: </p>
</div>
<div class="small-7 column">
<p class="bio-field-text">
Discipline Choice 3 </p>
</div>
</div>
<div class="column bio-card-btm-content">
<p>Example text</p>
<div style="clear:both;"></div>
</div>
</div>
</div>
UserSettingController
src/main/java
com.ui.usersetting.datamodel
com.ui.usersetting.restinterface
com.ui.usersetting.UserSettingController
resources
resources_deployment1
spring-resource1.xml
resources_deployment2
...
中有一个@Autowired JdbcTemplate变量
其定义出现在com.ui.usersetting.datamodel
中。
在resource/resources_deployment1/spring-resource1.xml
中还包含一个@Configuration文件
com.ui.usersetting.datamodel
。
这可以构建和部署,但是当我点击其中一个定义的端点时
@ImportResource("classpath:spring-resource1.xml")
,我从Spring得到以下错误:
com.ui.usersetting.restinterface
我认为这意味着class path resource [spring-resource1.xml] cannot be opened because it does not exist
,
其中包含UserSettingController/resources/resources_deployment1/
,不会出现在类路径中。我试过了
通过在Eclipse中设置类路径来解决这个问题,但是因为我使用Gradle构建
命令行命令而不是Eclipse,这个修复程序不起作用。
我需要维护上面的结构,而不是移动spring-resource1.xml
到spring-resource1.xml
,与我们小组中的其他项目保持一致。所以,
如何让Spring在src/main/resources
找到合适的位置?
答案 0 :(得分:1)
只需在resources
添加额外的sourceSets
个文件夹即可。假设您有3个resources_deployment
个文件夹:
sourceSets {
main {
resources {
(1..3).each {
srcDir "resources/resources_deployment$it"
}
}
}
}