javaの最近のブログ記事

カテゴリー:

SLF4J Error Codes

This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.

、、、ということなので、とりあえずpom.xmlに

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-api</artifactId>
	<version>1.6.1</version>
</dependency>

カテゴリー:

Tomcat5/6のGETリクエストで文字化け - @"かたち開発の開発日記"

Encoding problem for czech characters in HttpRequest parameters - Spring Community Forums

Tomcatのserver.xmlのConnector要素に以下の属性を設定する。

URIEncoding --- URIをデコードするときの文字エンコーディング。デフォルトはISO-8859-1。
useBodyEncodingForURI --- URIパラメータのデコードにサブミットしたフォームのページの文字エンコーディングを使用するかどうか。デフォルトはfalse。
(Apache Tomcat Configuration Reference - The HTTP Connector)

例:
<Connector port="8080" protocol="HTTP/1.1" 
       connectionTimeout="20000" 
       redirectPort="8443"
       URIEncoding="UTF-8" useBodyEncodingForURI="true" />

カテゴリー:

ソースのバージョン - TzlTTqTjの日記

mavenでのビルドで以下のようなエラーが。

[11,5] 注釈は -source 1.3 でサポートされていま
せん
(注釈を使用可能にするには、-source 5 以降を使用してください)
総称型は -source 1.3 でサポートされていません
(総称型を使用可能にするには、-source 5 以降を使用してください)

以下のように、pom.xmlにmaven-compiler-pluginのsourceとtargetを指定する。

<plugins>
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-compiler-plugin</artifactId>
		<configuration>
			<source>1.6</source>
			<target>1.6</target>
		</configuration>
	</plugin>
</plugins>

カテゴリー:

kadir pekel » Blog Archive » Debugging through Maven Tomcat plugin by Eclipse

Dealing with Eclipse-based IDE - Maven User - Codehaus

Spring-MVC/ステップ・バイ・ステップ/mavenプロジェクトのデバッグ - PukiWiki

上から2番目のリンク先に書いてあるけど、maven 2.0.8 以降なら、mvnDebugが使えるので、これが一番簡単。

$ cd project_path
$ mvnDebug tomcat:run
※mvnDebugはMAVEN_HOME/binにある。


次にEclipseのプロジェクトで右クリックして、Debug as > Debug Configuration... > Remote Java Application > new で debug。

カテゴリー:

mavenでのコンパイルで以下の警告が出る。

[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (SJIS actually) to copy filtered resources, i.e. build is platform dependent!

試験管のなかのコード :: Maven Resource Plugin のワーニング

pom.xmlに以下を追加したら出なくなった。

<project>
  ...
	<build>
	  ...
		<pluginManagement>
			<plugins>
				<plugin>
					<artifactId>maven-resources-plugin</artifactId>
					<configuration>
						<encoding>UTF-8</encoding>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>

カテゴリー:

[#MOJO-1076] org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet - jira.codehaus.org

mvn tomcat:run で org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet が発生する。

原因は、pom.xmlで

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

としていたから。

Servlet APIは、コンパイル時には必要だが実行時には不要(サーブレットコンテナにより提供される)なので、こういう場合はscopeにprovidedを指定する。

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

カテゴリー:

カテゴリー:

■ Mavenのローカルレポジトリを表すクラスパス変数M2_REPOをEclipseに追加する。

$ mvn eclipse:add-maven-repo -Declipse.workspace=<Eclipseのワークスペースのパス>

■ Maven形式でプロジェクトディレクトリを用意し、POMファイルを記述する。

■ プロジェクトのトップディレクトリでeclipse:eclipseゴールを実行する。

$ mvn eclipse:eclipse -DdownloadSources=true -Dwtpversion=2.0

-Dwtpversionについては以下を参照。

Maven Eclipse Plugin - WTP support

■ プロジェクトをEclipseにインポートする。


参考: 「Apache Maven 2.0入門 Java・オープンソース・ビルドツール」


カテゴリー:

カテゴリー: