今日の役に立たない一言 - Today’s Trifle! -

古い記事ではさまざまなテーマを書いていますが、2007年以降はプログラミング関連の話がほとんどです。

XMLのxsi:schemaLocationを変更したときにWhite spaces are required between publicId and systemIdエラーが発生する

SpringMVCでのログ出力にAspectを使いたくてぐぐってみた。

このあたりを参考にしつつプログラムを修正。

open technica: Spring MVCでアスペクト(インターセプター)を実装する
テックノート – Aspectjの@Before、@Afterを使ってメソッド前後にログ出力を入れる

servlet-context.xml を変更すると「White spaces are required between publicId and systemId」とかいうエラーが発生。

追加したばかりの <aop:aspectj-autoproxy /> を削除するとエラーが消える。
なんだこれー?とか思いつつぐぐってみたら、先頭のxsi:schemaLocation の中に記述してある順番が悪いとこのエラーが出るってことがわかった。

適当に並べ替えてみたら、エラーが消えた。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
			http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
			http://www.springframework.org/schema/mvc 
			http://www.springframework.org/schema/mvc/spring-mvc.xsd
			http://www.springframework.org/schema/context 
			http://www.springframework.org/schema/context/spring-context.xsd
			http://www.springframework.org/schema/tx 
			http://www.springframework.org/schema/tx/spring-tx.xsd
			http://www.springframework.org/schema/aop
			http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

  :
    <aop:aspectj-autoproxy />
</beans>