質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

Q&A

解決済

1回答

1894閲覧

「spotbugs」および「checkstyle」の使用方法

NaoMatsubayashi

総合スコア10

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

0グッド

0クリップ

投稿2022/05/30 02:19

編集2022/06/01 11:12

問題点

java言語の学習に励んでおります。
分野は『静的コード解析』でございます。
使用中のツールは、『SpotBugs』と『Checkstyle』であります。ビルドとして『Maven』も併用いたしております。
問題は、エラーの発生からプログラムが正常に動作しないことでございます。したがって、正常に動作する方法をお教え願います。ご回答、よろしくお願い申し上げます。
また、参考にいたしましたサイトや文書が複数とございます。末尾に記載いたしました。

詳細情報

下記は、ターミナル上に発生したエラーと、私が作成いたしましたpomファイルでございます。

terminal

1[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project second: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site failed: A required class was missing while executing org.apache.maven.plugins:maven-site-plugin:3.3:site: org/apache/maven/doxia/siterenderer/DocumentContent

pom.xml

1<project> 2 3 <modelVersion>4.0.0</modelVersion> 4 5 <groupId>second.testProbability</groupId> 6 <artifactId>second</artifactId> 7 <version>1.0.0</version> 8 9 <properties> 10 <maven.compiler.target>8</maven.compiler.target> 11 <maven.compiler.source>8</maven.compiler.source> 12 </properties> 13 14 <build> 15 <plugins> 16 <plugin> 17 <groupId>org.apache.maven.plugins</groupId> 18 <artifactId>maven-surefire-plugin</artifactId> 19 <version>3.0.0-M5</version> 20 </plugin> 21 <plugin> 22 <groupId>com.github.spotbugs</groupId> 23 <artifactId>spotbugs-maven-plugin</artifactId> 24 <version>4.7.0.0</version> 25 </plugin> 26 <plugin> 27 <groupId>org.apache.maven.plugins</groupId> 28 <artifactId>maven-checkstyle-plugin</artifactId> 29 <version>3.1.2</version> 30 <dependencies> 31 <dependency> 32 <groupId>com.puppycrawl.tools</groupId> 33 <artifactId>checkstyle</artifactId> 34 <version>10.2</version> 35 </dependency> 36 </dependencies> 37 </plugin> 38 </plugins> 39 </build> 40 41 <reporting> 42 <plugins> 43 <plugin> 44 <groupId>com.github.spotbugs</groupId> 45 <artifactId>spotbugs-maven-plugin</artifactId> 46 <version>4.7.0.0</version> 47 </plugin> 48 <plugin> 49 <groupId>org.apache.maven.plugins</groupId> 50 <artifactId>maven-checkstyle-plugin</artifactId> 51 <version>3.1.2</version> 52 <reportSets> 53 <reportSet> 54 <reports> 55 <report>checkstyle</report> 56 </reports> 57 </reportSet> 58 </reportSets> 59 </plugin> 60 </plugins> 61 </reporting> 62 63 <dependencies></dependencies> 64 65</project>

参考

スッキリわかるJava入門 実践編 第3版
spotbugsの公式サイト
MVN Repository
ご協力くださいました有識者様

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

原因

pom.xmlの書き方(pluginの指定の仕方)で、下記にあげた5つのポイントに問題があるように見えました。

<project> <modelVersion>4.0.0</modelVersion> <groupId>second.testProbability</groupId> <artifactId>second</artifactId> <version>1.0.0</version> <properties> <maven.compiler.target>8</maven.compiler.target> <maven.compiler.source>8</maven.compiler.source> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> </plugin> <!-- POINT_1: typeの間違い、冗長な記述 --> <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.6.0.2</version> <dependencies> <dependency> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs</artifactId> <version>4.7.0</version> <type>pom</type> ※←少なくともtypeは不要 </dependency> </dependencies> </plugin> <!-- POINT_1: --> <!-- POINT_2: groupId,artifactIdの間違い --> <plugin> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>10.2</version> </plugin> <!-- POINT_2: --> </plugins> </build> <reporting> <plugins> <!-- POINT_3: artifactIdの間違い --> <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs</artifactId> <version>4.7.0</version> </plugin> <!-- POINT_3: --> <!-- POINT_4: groupId,artifactIdの間違い --> <plugin> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>10.2</version> <reportSets> <reportSet> <reports> <report>checkstyle</report> </reports> </reportSet> </reportSets> </plugin> <!-- POINT_4: --> </plugins> </reporting> <dependencies> <!-- POINT_5: 不要? ここから--> <dependency> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs</artifactId> <version>4.7.0</version> <type>pom</type> </dependency> <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>10.2</version> </dependency> <!-- POINT_5: ここまで--> </dependencies> </project>

修正内容

5つのポイントの修正内容です。

POINT_1

この部分は以下のように書くことができます。

<plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.7.0.0</version> </plugin>

POINT_2

maven-checkstyle-plugin を使用するようにしてください。

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>3.1.2</version> <dependencies> <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>10.2</version> </dependency> </dependencies> </plugin>

POINT_3

spotbugs-maven-plugin を使用するようにしてください。

<plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.7.0.0</version> </plugin>

POINT_4

maven-checkstyle-plugin を使用するようにしてください。

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>3.1.2</version> <reportSets> <reportSet> <reports> <report>checkstyle</report> </reports> </reportSet> </reportSets> </plugin>

POINT_5

アプリケーションの内容まではわからないので必要かどうかは判断できないのですが、この部分(dependencyで定義するspotbugsとcheckstyleの依存関係)は不要に見えたのでいったんコメントアウトしてみてください。

以上よろしくお願いいたします。

追記 (2022/5/31)

  • build要素の maven-surefire-plugin のバージョンを 3.0.0-M6 へアップデートしてください。
  • build要素のpluginsに maven-site-pluginmaven-project-info-reports-plugin を追加してください。
  • reporting要素のpluginsに maven-project-info-reports-plugin を追加してください。
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M6</version> ※←バージョン変更 </plugin> <!-- 追加 ↓↓↓ --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>4.0.0-M1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.3.0</version> </plugin> <!-- 追加 ↑↑↑ --> </plugins> </build> <reporting> <plugins> <!-- 追加 ↓↓↓ --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.3.0</version> </plugin> <!-- 追加 ↑↑↑ --> </plugins> </reporting>

投稿2022/05/30 14:25

編集2022/05/31 13:26
rubytomato

総合スコア1752

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

NaoMatsubayashi

2022/05/31 02:21

ご回答、ありがとうございます。 ポイントごとにご解説くださいましたおかげで、私の理解も十分なものに昇華できたかと存じます。ただ、rubytomato様がご指摘なさったとおりの修正をいたしましたところ、新たなエラーが発生しました。 不躾を承知で申し上げます。そちらの問題にもお答えくださいますと、幸いです。 質問の『詳細情報』と『参考』のみ、編集いたしました。そちらを、ご覧ください。 最後になりますが、ご回答、誠にありがとうございました。
NaoMatsubayashi

2022/06/01 02:12

ご回答、ありがとうございます。 理解力の乏しい私に、最後までご丁寧な対応を、心より感謝いたします。 おかげさまで、私のプログラムは十二分なものとなりました。 ご回答、ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問