Intellij Idea Community Edition의 Tomcat
Intellij Idea Community Edition에서 Tomcat 서버를 사용하여 웹 애플리케이션을 실행할 수 있습니까?
나는 그것에 대한 정보를 찾으려고 노력했지만 성공하지 못했습니다.
maven을 사용하는 경우이 명령을 사용할 수 mvn tomcat:run
있지만 먼저 다음과 같이 pom.xml에이 구조를 빌드 태그에 추가합니다.
<build>
<finalName>mvn-webapp-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Intellij Community는 Java 애플리케이션 서버 통합을 제공하지 않습니다. 당신의 대안은
- Intellij 라이선스 구매,
- Eclipse로 전환;)
- Smart Tomcat 플러그인 설치 https://plugins.jetbrains.com/plugin/9492
- IDEA Jetty Runner 플러그인 설치 https://plugins.jetbrains.com/plugin/7505
- 다른 답변에 설명 된대로 Maven, Gradle 등에서 애플리케이션 서버를 실행합니다.
개인적으로 Jetty Runner 플러그인을 설치했으며 (Jetty는 괜찮습니다. Tomcat이 필요하지 않습니다)이 솔루션에 만족합니다. 나는 IntelliJ 아이디어 를 다루어야했다 -Jetty는 예외를보고했다 .
Maven을 사용하여 다음을 시도하십시오 tomcat7-maven-plugin
.
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextFile>src/main/webapp/WEB-INF/config/app-config.xml</contextFile>
<mode>context</mode>
<charset>UTF-8</charset>
<warDirectory>target/${project.artifactId}-${project.version}</warDirectory>
</configuration>
</plugin>
</plugins>
</build>
사용하여 실행 tomcat7:run-war
여기에 더 많은 목표
예, Maven 플러그인 또는 간단한 Java 프로그램을 사용할 수 있습니다. IDE 플러그인이 필요하지 않습니다. 예를 들어 https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat의 Main 클래스를 참조하십시오.
Tomcat은 IntelliJ Idea-Community Edition과 Tomcat Runner 플러그인을 통합 할 수도 있습니다.
아래 세부 정보 : https://plugins.jetbrains.com/plugin/8266-tomcat-runner-plugin-for-intellij
Tomcat (Headless)은 IntelliJ Idea-Community Edition과 통합 될 수 있습니다.
단계별 지침은 다음과 같습니다.
tomcatX-maven-plugin
pom.xml에 추가<build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>SampleProject</path> </configuration> </plugin> </plugins> </build>
아래와 같이 새 실행 구성을 추가합니다.
Run >> Edit Configurations >> + >> Maven Parameters tab ... Name :: Tomcat Working Directory :: Project Root Directory Command Line :: tomcat7:run Runner tab ... VM Options :: <user needed options> JRE :: <project needed>
IntelliJ Run >> Run / Debug 메뉴에서 직접 Run / Debug 모드로 Tomcat을 호출합니다.
참고 : 이것은 IntelliJ-Enterprise 버전 기능의 Tomcat 통합 기능을 사용하는 해킹으로 간주되지만 Tomcat을 IntelliJ Idea-커뮤니티 에디션에 통합하는 프로그래밍 방식이라고 생각합니다.
예, 가능하고 상당히 쉽습니다.
- 실행 버튼 근처의 드롭 다운에서 "구성 편집 ..."을 선택합니다.
- 왼쪽에서 더하기를 클릭 한 다음 maven을 클릭하고 오른쪽에서 "Tomcat"으로 이름을 바꿉니다.
- 명령 줄에 "spring-boot : run"을 입력합니다.
- 실행기 탭에서 'VM 옵션'에 "-XX : MaxPermSize = 256m -Xms128m -Xmx512m -Djava.awt.headless = true"를 입력합니다. 참고 : '프로젝트 설정 사용'은 선택 해제해야합니다.
- 환경 변수의 경우 "env = dev"를 입력합니다.
- 마지막으로 확인을 클릭합니다.
실행을 누를 준비가되었을 때 "localhost : 8080 / <page_name>"로 이동하면 페이지가 표시됩니다.
내 pom.xml 파일은 Spring MVC로 웹 콘텐츠를 제공 하는 공식 봄 자습서와 동일합니다.
<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework</groupId>
<artifactId>gs-serving-web-content</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
maven 플러그인과 임베디드 Tomcat은 사용 가능한 해결 방법이지만 (디버그 할 수 있기 때문에 두 번째로 더 좋습니다) 실제 웹 서버 통합은 인텔 리즈 유료 에디션에서만 사용할 수있는 기능입니다.
gradle과 함께 tomcat 플러그인을 사용할 수 있습니다. 자세한 내용은 여기 .
apply plugin: 'tomcat'
dependencies {
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.4'
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
[tomcatRun, tomcatRunWar, tomcatStop]*.stopPort = 8090
[tomcatRun, tomcatRunWar, tomcatStop]*.stopKey = 'stfu'
tomcatRunWar.contextPath = "/$rootProject.name"
tomcatRunWar.ajpPort = 8000
if (checkBeforeRun.toBoolean()) {
tomcatRunWar { dependsOn += ['check'] }
}
I am using intellij CE to create the WAR, and deploying the war externally using tomcat deployment manager. This works for testing the application however I still couldnt find the way to debug it.
- open cmd and current dir to tomcat/bin.
- you can start and stop the server using the batch files start.bat and shutdown.bat.
- Now build your app using mvn goal in intellij.
- Open localhost:8080/ **Your port number may differ.
- Use this tomcat application to deploy the application, If you get the authentication error, you would need to set the credentials under conf/tomcat-users.xml.
I used Jay Lin's answer. Highly recommend it.
If you never used Maven before and don't want to go deep into it: follow Jay Lin's answer, but also do this:
right click on your project name -> Add Framework support -> Maven.
Then install maven from here http://maven.apache.org/install.html. Do what it says, run the commands.
Then install spring-boot from here https://mvnrepository.com.
Then follow the error messages if there are any - maybe you would need to install some other stuff (just google it and that mvnrepository.com would come up). To install use this command:
mvn install:install-file -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile=path
replace path
with where you downloaded the jar
file, replace version, group and artifact id with info from mvnrepository.com.
- Further errors I encountered:
I had to create a class in src/main/java (with simple System.out.println
command in main) and add <start-class>main.java.Hello</start-class>
in <properties>
tag in pom.xml
. Btw, the pom.xml
should appear itself when you do the first action from my answer - copy paste Jay Lin's code there.
Another error I got was connected to JAVA_HOME
variable and the verion stuff. Somewhy it thought jdk is 7th version and I was telling it was 8th. So I changed the java version tag in <properties>
to this <java.version>1.7</java.version>
.
Now it works fine! Good luck everyone.
For Intellij 14.0.0 the Application server option is available under View > Tools window > Application Server (But if it is enable, i mean if you have any plugin installed)
VM :-Djava.endorsed.dirs="C:/Program Files/Apache Software Foundation/Tomcat 8.0/common/endorsed"
-Dcatalina.base="C:/Program Files/Apache Software Foundation/Tomcat 8.0"
-Dcatalina.home="C:/Program Files/Apache Software Foundation/Tomcat 8.0"
-Djava.io.tmpdir="C:/Program Files/Apache Software Foundation/Tomcat 8.0/temp"
-Xmx1024M
참고URL : https://stackoverflow.com/questions/22047860/tomcat-in-intellij-idea-community-edition
'IT TIP' 카테고리의 다른 글
std :: stoi는 실제로 사용하기에 안전합니까? (0) | 2020.12.12 |
---|---|
Google Play 오류 "[DF-DFERH-01] 서버에서 정보를 검색하는 동안 오류 발생" (0) | 2020.12.12 |
"new Date (int year, int month, int day)"가 더 이상 사용되지 않는 이유는 무엇입니까? (0) | 2020.12.12 |
C ++에서 컴파일러 및 인수 평가 순서 (0) | 2020.12.12 |
ggplot2에서 글꼴 수정 (0) | 2020.12.12 |