タグ付けされた質問 「spring」

Spring Frameworkは、Javaプラットフォームでのアプリケーション開発のためのオープンソースフレームワークです。中核となるのは、コンポーネントベースのアーキテクチャに対する豊富なサポートであり、現在、20を超える高度に統合されたモジュールを備えています。

3
春:静的フィールドに値を注入する方法は?
このクラスで @Component public class Sample { @Value("${my.name}") public static String name; } 試してみるとSample.name、常に「null」です。だから私はこれを試しました。 public class Sample { public static String name; @PostConstruct public void init(){ name = privateName; } @Value("${my.name}") private String privateName; public String getPrivateName() { return privateName; } public void setPrivateName(String privateName) { this.privateName = privateName; } } …

2
@Autowired Beanは、別のBeanのコンストラクターで参照されるとnullになります。
以下に示すのは、ApplicationProperties Beanを参照するコードスニペットです。コンストラクタから参照するとnullになりますが、別のメソッドから参照すると問題ありません。これまで、他のクラスでこのautowired Beanを使用することに問題はありませんでした。しかし、これを別のクラスのコンストラクターで使用しようとしたのはこれが初めてです。 以下のコードスニペットでは、コンストラクターから呼び出されたときにapplicationPropertiesがnullになっていますが、convertメソッドで参照された場合はnullになりません。何が欠けている @Component public class DocumentManager implements IDocumentManager { private Log logger = LogFactory.getLog(this.getClass()); private OfficeManager officeManager = null; private ConverterService converterService = null; @Autowired private IApplicationProperties applicationProperties; // If I try and use the Autowired applicationProperties bean in the constructor // it is null ? public DocumentManager() …
89 java  spring  autowired 

3
org.springframework.mailのどのアーティファクト?
メール送信に春のサポートを利用したいのですが。私のプロジェクトはmaven-2でビルドされており、Spring-core 2.5.5を使用しています。pom.xmlに含めるアーティファクトをMavenセントラルリポジトリで調べようとしましたが、見つかったのはSpringサポートのみです。問題は、リポジトリの最高バージョンが2.0.8であり、Spring-Core v。2.0.8に依存していることです。それを追加して依存関係から除外する必要がありますspring-core、spring-aopなど、または別のアーティファクトを探すべきですか(どちらが行うのですか?)または別のリポジトリを使用する必要がありますか?org.springframework.mailに適切なmaven-2アーティファクトはどれですか。どこにありますか?

3
Spring @ResponseBodyアノテーションはどのように機能しますか?
次のように注釈が付けられたメソッドがあります。 /** * Provide a list of all accounts. */ // TODO 02: Complete this method. Add annotations to respond // to GET /accounts and return a List<Account> to be converted. // Save your work and restart the server. You should get JSON results when accessing // http://localhost:8080/rest-ws/app/accounts @RequestMapping(value="/orders", method=RequestMethod.GET) …
89 java  json  spring  rest  spring-mvc 

6
Spring Securityで「X-Frame-Options」応答ヘッダーを無効にする方法は?
jspにCKeditorがあり、何かをアップロードするたびに、次のエラーが表示されます。 Refused to display 'http://localhost:8080/xxx/xxx/upload-image?CKEditor=text&CKEditorFuncNum=1&langCode=ru' in a frame because it set 'X-Frame-Options' to 'DENY'. Spring Securityを削除してみましたが、すべてが魅力のように機能します。Spring Security xmlファイルでこれを無効にするにはどうすればよいですか?<http>タグの間に何を書くべきですか

16
@ Autowired-依存関係に適したタイプのBeanが見つかりません
SpringとHibernateを使用して、エンティティ、サービス、およびサービスのJUnitテストを作成することからプロジェクトを開始しました。これはすべてうまく機能します。次に、さまざまなステップバイステップのチュートリアルを使用してこのWebアプリケーションを作成するためにspring-mvcを追加しましたが、@ Autowiredアノテーションを使用してコントローラーを作成しようとすると、デプロイ中にGlassfishからエラーが発生します。どういうわけかSpringは私のサービスを認識していないと思いますが、何度も試みてもまだ処理できません。 を使用したサービスのテスト @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:/beans.xml"}) そして @Autowired MailManager mailManager; 正しく動作します。 @Autowiredのないコントローラーも、問題なくWebブラウザーでプロジェクトを開くことができます。 /src/main/resources/beans.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:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"> <context:property-placeholder location="jdbc.properties" /> <context:component-scan base-package="pl.com.radzikowski.webmail"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!--<context:component-scan …

6
Spring BootとMongoDBへの接続の詳細を構成する方法は?
Spring Bootを初めて使用するので、MongoDBの接続の詳細をどのように構成できるのか疑問に思っています。通常の例を試しましたが、接続の詳細については説明していません。 使用するデータベースと、MongoDBを実行するホストのURL /ポートを指定したいと思います。 ヒントやヒントはありますか?

8
@ComponentScanアノテーションを使用して複数のパスをスキャンする方法は?
Spring 3.1を使用していて、@Configurationand@ComponentScan属性を使用してアプリケーションをブートストラップしています。 実際のスタートは new AnnotationConfigApplicationContext(MyRootConfigurationClass.class); この構成クラスには注釈が付けられています @Configuration @ComponentScan("com.my.package") public class MyRootConfigurationClass これは問題なく動作します。ただし、スキャンするパッケージについてより具体的にしたいので、試してみました。 @Configuration @ComponentScan("com.my.package.first,com.my.package.second") public class MyRootConfigurationClass ただし、これは失敗し、@Component注釈を使用して指定されたコンポーネントが見つからないというエラーが表示されます。 私が求めていることを行う正しい方法は何ですか? ありがとう

4
JpaRepositoryDML操作ではサポートされていません[クエリの削除]
インターフェース拡張の一部のオブジェクトを削除するクエリを作成しましたが、クエリJPaRepositoryを実行すると例外がスローされます。誰かが私のためにそれを説明できますか? クエリ: public interface LimitRepository extends JpaRepository<CLimit, Long> { @Query("delete from CLimit l where l.trader.id =:#{#trader.id}") void deleteLimitsByTrader(@Param("trader") CTrader trader); } 私はこのエラーを受け取りました、誰でもできます、私のためにこれを説明してください、そしてすべてに感謝します:) 例外: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [delete from com.query.domain.CLimit l where l.trader.id =:__$synthetic$__1] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.errorIfDML(QueryTranslatorImpl.java:318) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:369) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1300) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:495) …

12
SpringBootのresourcesフォルダーからファイルを読み取ります
SpringBootとを使用していjson-schema-validatorます。フォルダjsonschema.jsonから呼び出されたファイルを読み取ろうとしていresourcesます。私はいくつかの異なる方法を試しましたが、それを機能させることができません。これは私のコードです。 ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("jsonschema.json").getFile()); JsonNode mySchema = JsonLoader.fromFile(file); これはファイルの場所です。 そして、ここで私はclassesフォルダ内のファイルを見ることができます。 しかし、コードを実行すると、次のエラーが発生します。 jsonSchemaValidator error: java.io.FileNotFoundException: /home/user/Dev/Java/Java%20Programs/SystemRoutines/target/classes/jsonschema.json (No such file or directory) コードで何が間違っているのですか?

13
Spring AOP:JoinPointとPointCutの違いは何ですか?
私はアスペクト指向プログラミングの概念とSpring AOPを学んでいます。ポイントカットとジョインポイントの違いを理解できていません。どちらも同じように見えます。ポイントカットはアドバイスを適用する場所であり、ジョインポイントはアドバイスを適用できる場所でもあります。次に、違いは何ですか? ポイントカットの例は次のとおりです。 @Pointcut("execution(* * getName()") ジョインポイントの例は何ですか?

7
サーブレットとWebサービスの違い
これら2つの違いは何ですか?Googleでの結果はほとんどありませんでした。 これはフォローアップの質問です: いくつかのクラスに@Controllerアノテーションを付けたSpring MVC Webアプリを作成し、フロントエンドからバックエンドに情報を正常に転送できるものを作成するとします。バックエンド側にデータベースが含まれている可能性があります。 なんていうの?Webサービス、サーブレット、または他の何かを休止しますか?

15
Hibernate-シーケンスは存在しません
春の4.2バージョンを使用して、プロジェクトでHibernateを4から5にアップグレードしようとしました。このアップグレード後、更新メソッドを呼び出したときに、スタックトレースに次のエラーが見つかりました。 10:53:32,185 ERROR TableStructure:149 - could not read a hi value com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist アノテーション付きの自動インクリメントIDを変更しました @GeneratedValue(strategy=GenerationType.AUTO) それでもエラーは残ります。
88 java  spring  hibernate 

8
SpringでSessionオブジェクトを取得するにはどうすればよいですか?
私はSpringとSpringのセキュリティに比較的慣れていません。 Springセキュリティを使用してサーバー側でユーザーを認証する必要があるプログラムを作成しようとしていました。 私は次のことを思いついた: public class CustomAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider{ @Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) throws AuthenticationException { System.out.println("Method invoked : additionalAuthenticationChecks isAuthenticated ? :"+usernamePasswordAuthenticationToken.isAuthenticated()); } @Override protected UserDetails retrieveUser(String username,UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { System.out.println("Method invoked : retrieveUser"); //so far so good, i can authenticate user here, and throw …


弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.