I have gone through https://github.com/spring-projects/spring-boot/issues/424 but my project structure contains .html files at the /templates diretory as shown below
.
|-- java
| `-- com
| `-- projectx
| |-- config
| | |-- Application.java
| | `-- WebXmlInitialiser.java
| |-- controller
| | `-- CustomerQuickRegisterController.java
| |-- domain
| | `-- Email.java
| `-- services
| |-- CustomerQuickRegisterDataFixtures.java
| |-- CustomerQuickRegisterHandler.java
| `-- CustomerQuickRegisterService.java
`-- resources
|-- application.properties
`-- templates
|-- emailForm.html
`-- result.html
But still while testing with following test
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest
@ActiveProfiles("Test")
public class CustomerQuickRegisterControllerIntergrationTest {
@Autowired
private WebApplicationContext wac;
MockMvc mockMvc;
@Before
public void setUp()
{
this.mockMvc=MockMvcBuilders.webAppContextSetup(wac).build();
}
@Test
public void thatEmailAddedSucessfully() throws Exception {
this.mockMvc.perform(
post("/email/addemail")
It is giving error as
java.lang.IllegalStateException: Cannot find template location: class path resource [templates/] (please add some templates or check your Thymeleaf configuration)
But when I am running this project as gradle build:bootRun
it works fine.Also .war file created from this project works well. I am not sure what's problem when i am testing it.
I checked and there was problem in IDE. And now It is working fine. Initially i was confused because the gradle:bootRun
was working fine and i was able to access those view HTML files.