1

私のプロセスクラス:

@Configurable("checkLicense")
public class CheckLicense {
String licensePath ;

@Value("${licenseKeyNotFound}")
String licenseKeyNotFound;

    public boolean checkIn(String licensepath) {
        System.out.println("hello "+licenseKeyNotFound);
        licensePath = licensepath;
        return checkIn();
    }

}

私のApplicationContext.xml

<?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:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <bean class="com.smart.applicationlicense.CheckLicense"
        scope="prototype">
    </bean>
</beans>

これが私のプロパティファイルです。

licenseKeyNotFound = License File Corrupted

これが私のサーブレットxmlです。

<context:property-placeholder location="conf/LicenseSettings.properties"
    order="2" ignore-unresolvable="true" />

@Configurableattributesとともに注釈を使用しましたが、プロパティ ファイルからのAutowire.BY_NAME, Autowire.BY_TYPE変数を開始できません。 コントローラーから変数を開始できましたが、宣言されているこのクラスからは開始できませんでした。licenseKeyNotFound
@Configurable

誰かが私に欠けているものやコードの何が問題なのか教えてもらえますか?
私のコードに何か必要なものがあるかどうか教えてください。

4

2 に答える 2

1

これを試して:

あなたの春のxmlで:

<context:property-placeholder location="classpath:your.properties" />
<context:load-time-weaver />
于 2013-01-23T10:50:02.490 に答える
0

これを試して

@Configurable
public class CheckLicense {
   String licensePath;
   String licenseKeyNotFound;

   @Value("${licenseKeyNotFound}")   
   public void setLicenseKeyNotFound(String licenseKeyNotFound) {
      this.licenseKeyNotFound = licenseKeyNotFound;
   }

   public boolean checkIn(String licensepath) {
      System.out.println("hello " + licenseKeyNotFound);
      licensePath = licensepath;
      return checkIn();
   }
}

あなたのプロパティファイルで

licenseKeyNotFound=${value}
于 2013-01-23T10:19:00.637 に答える