I am using Eclipse and I don't have Tomcat registered in Server view (please don't say me to add new server).
I started the debug mode in Eclipse by doing two settup in Debug Configurations
1 - enter "clean install tomcat7:run-war -Dspring.profiles.active=development" in Goals under Main tab
2 - and added the project in Source tab.
The Tomcat starts and I can debug perfectly the java code. The problem is, whenever I change a small thing in java or html, if I don't stop and start again via "clean install tomcat7:run-war -Dspring.profiles.active=development" it will not take effect at all. You can imagine I am losing time.
I read somewhere that I can copy and paste the html and class edited files straight in target directory but target/tomcat only contains conf and log folders. In target I do see my_app.war. Btw, it must exist a better way to make the changed code be refreshed by Tomcat.
The straight question is: How to make the changes in my source be automatically re-publish to Embedded Tomcat when starting the debug with tomcat7:run-war?
I saw several forum topics teaching how to do it with a server registered in Eclipse but my case is a bit different.
I guess, but I have no idea what, I am doing something wrong here "installsources..."
The closest topic I have found is
How to run tomcat7-maven-plugin, that server code changes will be updated immediately
In this question, basically, I found two suggestions:
1 - Turn off the test scripts (well, it is still necessary to re-start the embedded server although a bit faster in some scenarios)
2 - Use "redeploy". I tried "clean install tomcat7:redeploy -Dspring.profiles.active=development" and I got:
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project calories-tracker: Failed to clean project: Failed to delete
Relevant part of development profile configuration:
@Configuration
@Profile("development")
@EnableTransactionManagement
public class DevelopmentConfiguration {
@Bean(name = "datasource")
public DriverManagerDataSource dataSource() {
…
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource) {
…
Relevant part of pom.xml:
<packaging>war</packaging>
<properties>
<java-version>1.8</java-version>
<org.springframework-version>4.1.3.RELEASE</org.springframework-version>
<spring-security-version>3.2.5.RELEASE</spring-security-version>
<hibernate.version>4.3.7.Final</hibernate.version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<jackson-version>2.4.4</jackson-version>
<postgres.driver.version>9.3-1100-jdbc41</postgres.driver.version>
</properties>
<build>
<finalName>my_app</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<httpsPort>8443</httpsPort>
<keystoreFile>${basedir}/other/keystore.jks</keystoreFile>
<keystorePass>secret</keystorePass>
</configuration>
</plugin>
</plugins>
</build>