・javaインストール
# cd /opt# wget https://services.gradle.org/distributions/gradle-8.10-bin.zip
# unzip gradle-8.10-bin.zip
# ln -s gradle-8.10 gradle
# vi /etc/profile.d/gradle.sh <<__EOF__
export GRADLE_HOME=/opt/gradle
export PATH=$GRADLE_HOME/bin:$PATH
__EOF__
$ source /etc/profile
$ cd Make
$ mkdir gradle_app
$ cd gradle_app
$ mkdir -p src/main/java/com/example
$ mkdir -p src/main/webapp/WEB-INF
$ vi build.gradle <<__EOF__
plugins {
id 'war'
}
repositories {
mavenCentral()
}
dependencies {
// Jakarta Servlet 5.0 API
// https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api
providedCompile 'jakarta.servlet:jakarta.servlet-api:5.0.0'
}
// Java 22
sourceCompatibility = 22
targetCompatibility = 22
// Application
version = '1.0'
__EOF__
$ vi src/main/webapp/WEB-INF/web.xml <<__EOF__
<?xml version="1.0" encoding="UTF-8"?>
<!-- Web Application Deployment Descriptor (Jakarta Servlet 5.0) -->
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
<servlet>
<servlet-name>myjsp</servlet-name>
<jsp-file>/myjsp.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>myjsp</servlet-name>
<url-pattern>/myjsp</url-pattern>
</servlet-mapping>
</web-app>
__EOF__
$ vi src/main/java/com/example/MyServlet.java
$ vi src/main/webapp/myjsp.jsp
$ gradle build
$ tree
.
├── build
│ ├── classes
│ │ └── java
│ │ └── main
│ │ └── com
│ │ └── example
│ │ └── MyServlet.class
│ ├── generated
│ │ └── sources
│ │ ├── annotationProcessor
│ │ │ └── java
│ │ │ └── main
│ │ └── headers
│ │ └── java
│ │ └── main
│ ├── libs
│ │ └── gradle_app-1.0.war
│ └── tmp
│ ├── compileJava
│ │ └── previous-compilation-data.bin
│ └── war
│ └── MANIFEST.MF
├── build.gradle
└── src
└── main
├── java
│ └── com
│ └── example
│ └── MyServlet.java
└── webapp
├── WEB-INF
│ └── web.xml
└── myjsp.jsp
# cp -p build/libs/gradle_app-1.0.war /opt/tomcat/webapps/
URL: localhost/gradle_app/myjsp
【SELINUX】
sestatus
sudo dnf install policycoreutils-python-utils
sudo grep tomcat /var/log/audit/audit.log
sudo chcon -R -t tomcat_exec_t /opt/tomcat
sudo chcon -R -t tomcat_var_lib_t /opt/tomcat/logs
sudo audit2allow -a -M tomcat-custom
sudo semodule -i tomcat-custom.pp
sudo restorecon -R -v /opt/tomcat
0 件のコメント:
コメントを投稿