当前位置: 首页 > 知识库问答 >
问题:

IntelliJ Java编辑。jsp无服务器重启[重复]

公羊英达
2023-03-14

我是一名前端web开发人员,我得到了一个Java项目,我的任务是开发前端。jsp文件(html / css / js)。

我已经在IntelliJ社区版15中设置了该项目,它使用Maven运行良好:

mvn -Denv=local tomcat7:run-war

编译只需要1分30秒,等待这么长时间只是为了看到一个简单的CSS / HTML更改是令人沮丧的。

我被告知IntelliJ可以以某种方式设置它,这样我就可以编辑. jsp文件并即时查看更改,而无需重新启动tomcat。

但怎么做呢?(正如您可能猜到的那样,我对Java/Maven/Tomcat知之甚少)

我在IntelliJ中得到这个Maven窗口,如下所示:

还有一个POM文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xxxx</groupId>
    <artifactId>hermes</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>hermes</name>

    <properties>
        <java.version>1.6</java.version>
        <hibernate.version>5.0.3.Final</hibernate.version>
        <org.springframework.version>4.2.1.RELEASE</org.springframework.version>
        <org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
        <org.springframework.amqp.version>1.3.5.RELEASE</org.springframework.amqp.version>
        <jackson.version>2.5.0</jackson.version>
        <google.simple.spring.memcached.version>3.6.0</google.simple.spring.memcached.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.34</version>
        </dependency>
        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>


        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <!-- jsr303 validation -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.simple-spring-memcached</groupId>
            <artifactId>spring-cache</artifactId>
            <version>${google.simple.spring.memcached.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-asm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.code.simple-spring-memcached</groupId>
            <artifactId>spymemcached-provider</artifactId>
            <version>${google.simple.spring.memcached.version}</version>
        </dependency>
        <dependency>
            <groupId>com.rometools</groupId>
            <artifactId>rome</artifactId>
            <version>1.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom2</artifactId>
            <version>2.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.2</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
            <optional>false</optional>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>dbcore-utils</groupId>
            <artifactId>jdbc-driver-oracle11g</artifactId>
            <version>1.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.github.kevinsawicki</groupId>
            <artifactId>http-request</artifactId>
            <version>6.0</version>
        </dependency>

        <!-- Rabbit/JMS/AMQP -->
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>javax.jms-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
            <version>${org.springframework.amqp.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-amqp</artifactId>
            <version>${org.springframework.amqp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>3.3.4</version>
        </dependency>

        <dependency>
            <groupId>com.xxxx</groupId>
            <artifactId>atlas</artifactId>
            <version>1.0.1-RELEASE</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-jms</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


    </dependencies>

    <repositories>
        <repository>
            <id>maven.xxxx.net</id>
            <url>http://maven.xxxx.net:8080/artifactory/libs-releases-local/</url>
        </repository>
        <repository>
            <id>spring libs milestones</id>
            <url>http://repo.springsource.org/libs-milestone/</url>
        </repository>
        <repository>
            <id>EclipseLink</id>
            <url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
        </repository>
        <repository>
            <id>Couchbase</id>
            <url>http://files.couchbase.com/maven2/</url>
        </repository>
        <repository>
            <id>Java.net</id>
            <url>http://download.java.net/maven/2/</url>
        </repository>
        <repository>
            <id>mavenrepository.com</id>
            <url>repo1.maven.org/maven2/</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.milestone</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Milestone Releases</name>
            <url>http://repository.springsource.com/maven/bundles/milestone</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Releases</name>
            <url>http://repository.springsource.com/maven/bundles/external</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>plugins-releases</name>
            <url>http://maven.xxxx.net:8080/artifactory/plugins-releases</url>
        </pluginRepository>
        <pluginRepository>
            <snapshots />
            <id>snapshots</id>
            <name>plugins-snapshots</name>
            <url>http://maven.xxxx.net:8080/artifactory/plugins-snapshots</url>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <finalName>hermes</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/classes</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/java</directory>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>src/main/resources/spring</directory>
                                    <targetPath>META-INF</targetPath>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.xxxx.hermes.app.Hermes</mainClass>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                    <resources>
                                        <resource>.java</resource>
                                    </resources>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Useful for purging local repository and re-downloading all dependencies 
                in event of major/minor version conflicts -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <port>8891</port>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <packagingExcludes>
                        WEB-INF/classes/com/xxxx/**/*.java,WEB-INF/lib/servlet*.jar
                    </packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

共有2个答案

宋明亮
2023-03-14

问题是使用了“run-war”目标。它运行应用程序的“打包”版本。尝试运行:

tomcat7:run

(而不是“运行-战争”-这只是你展示的窗口中的一个目标)IntelliJ中的Maven窗口看起来像这样

您可能还需要将其添加到pom中的依赖项中.xml

 <dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>servlet-api</artifactId>
     <version>2.5</version>
     <scope>provided</scope>
 </dependency>

这为我完成了工作:现在我可以很容易地编辑html / css / js文件(在运行中),而不需要不断地重启和重新部署tomcat。

司空锋
2023-03-14

我知道你有社区版。如果您要升级到Ultimate版本,那么您可以

  1. 启用Intellij以部署到Tomcat。看见https://www.jetbrains.com/idea/help/defining-application-servers-in-intellij-idea.html
  2. 为您的hermes web应用程序创建运行配置。单击运行菜单、编辑配置菜单项。单击[]按钮添加配置。选择Tomcat服务器,本地
  3. 单击部署选项卡。
  4. 在Deploy at server startup部分下,单击[]以添加部署。选择赫密士:战争爆发
  5. 单击[确定]
  6. 现在,在“运行”菜单中,单击“调试”。这将在运行调试的Tomcat中启动您的hermes web应用程序
  7. 编辑JSP文件
  8. 现在,在运行菜单中,单击更新“未命名”应用程序。在更新“未命名”对话框中,选择“更新资源”和[确定]。这将重新部署您的JSP更改。请注意,这有一些快捷方式。在我的IntelliJ中,我可以按命令F10Enter快速重新部署更改
 类似资料:
  • 服务器重启后无法启动Apache HTTPD。我们 /etc/httpd/conf/拥有功能。用户/组。因此,我们使用脚本来启动httpd.conf每次服务器重启时,我们都无法启动HTTPD。我们发现 /var/run/httpd在重启后被更改为apache/root。因此,脚本无法启动功能下的HTTPD。用户/组。 请帮帮我!!!

  • 首先,允许我编辑minecraft服务器代码吗? 并且我在IntelliJ中获得了minecraft_server.jar的源代码,但是如果我想编译,我会得到100个错误,因为代码中有以下内容: 我真的不知道如何处理这些错误,因为在finshed jar中,它就像我的例子一样。 Minecraft服务器:https://Minecraft.net/download

  • 问题内容: 我已经安装并正在osx上运行一个node.js服务器。我已经释放了一个聊天模块,并且正在愉快地运行它。我更改了一些内容,需要重新启动服务器才能看到效果。 我只知道如何通过关闭终端窗口,然后重新对其进行操作,然后再次运行节点chatdemo.js来重新启动。 有什么方法可以重启而不关闭终端吗? 谢谢。 问题答案: 如果它仅在运行(不是守护程序),则使用。 如果是守护进程,则可以尝试: 凡

  • 更新时间:2019-05-30 15:23:09 创建服务后就可以进入服务开发编辑器的界面,首先我们来看下编辑器有哪些基本功能。 (小技巧:你可以点击区域6中的新手引导会弹出引导界面对整个工作台做一个了解) 编辑器整体概览 标签选项,可以进行左侧菜单筛选服务列表、节点列表、扩展服务的切换。 区域为左侧面板。 区域为当前项目,可以点击项目名称打开项目详情页面。 为菜单列表,显示编辑器中可提供操作的功

  • SEVERE:Web应用程序[/webapps/bb-nautilus-BBLEARN]似乎已启动名为[MessageQueueHandler-bb-nautilus-Content ent-blitz-0]的线程,但未能阻止它。这很可能造成内存泄漏。

  • 我正在用Jax-rs框架在eclipse中开发一个web应用程序,并在TomEE plus服务器上运行它。我之所以使用TomEE Plus而不是标准tomcat,是因为我想用jax rs编写我的应用程序,而jax rs不受标准tomcat的支持,每次运行应用程序时都会出现404。我下载了TomEE-Plus-9.0.0-M7,并将其添加到eclipse中,方法是将类型设置为Tomcat v10.0