私はマルチモジュールプロジェクトをwildfly-swarmに変換しようとしています。しかし、私はそれを正しく設定する方法を知らない。wildfly-swarm-pluginを使用したマルチモジュールMavenプロジェクト
コアディレクトリからmvn wildfly-swarm:run
を実行すると、サーバーが起動し、永続性ユニットが見つからないというエラーが表示されます。 persistence.xml
はモジュールにありますので意味があります。
私はルートディレクトリから実行しようとしましたが、プラグイン群は定義されていません。そこで、 pom.xmlにcore
のモジュールpom.xmlの代わりにプラグインを定義しようとしましたが、-swarm.jar
は作成できません。
どうすれば設定するのですか?
は、その後、私はcore.xmlに追加これは私のルートのpom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xxx</groupId>
<artifactId>x</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<version.wildfly.swarm>1.0.0.Final</version.wildfly.swarm>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>bom</artifactId>
<version>${version.wildfly.swarm}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>backgroundServices</module>
<module>core</module>
<module>DBLayer</module>
<module>userArea</module>
</modules>
<dependencies>
<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Wildfly Swarm Fractions -->
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>cdi</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jpa-mysql</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jsf</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>keycloak</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>logging</artifactId>
</dependency>
</dependencies>
</project>
です:
<build>
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
コアポンポン:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>xxx</groupId>
<artifactId>x</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>xxx</groupId>
<artifactId>DBLayer</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xxx</groupId>
<artifactId>backgroundServices</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
DBlayerポンポン:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>xxx</groupId>
<artifactId>x</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>DBLayer</artifactId>
</project>
を
私は主な方法を指定しませんでした。私はちょうど下DBLayer内のpersistence.xmlを持っています。だから私はちょっとその群れを想定していDBLayer/srcに/メイン/リソース/ META-INF
すると、ドライバを定義するために、自動的に世話をし、情報元。つまり、wildflyでドライバとデータソースをstandalone.xmlで定義する必要があります。ここで私はそれを何もしなかったので、おそらくそれは実際問題です。しかし、彼らの例ではどちらもしません。マルチモジュールMavenプロジェクトで
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="my-pu" transaction-type="JTA"> <jta-data-source>java:/walbangDbDS</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode> <properties> <!--<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>--> <!--<property name="javax.persistence.sql-load-script-source" value="sql_scripts/loading_script.sql"/>--> <property name="hibernate.enable_lazy_load_no_trans" value="true"/> </properties> </persistence-unit> </persistence>
私はstacktraceを十分に読まなかったが、私の悪いことはしなかった。私は思った通りです。 – Ced
@Cedデータソースは 'standaloneで正しく作成されていますか?xml'?あなたは 'faces-config.xml'を持っていますか(私はあなたがJSF依存関係を使用しているのを見ています)?最低限の設定で、 'persistence.xml'の中で' jta-data-source'、 'exclude-unlisted-classes'、' shared-cache-mode'を削除するとWARが正常に起動します。 – Tunaki
いいえ私はどこにでもstandalone.xmlを置かなかったので、mysqlにアクセスするパスワードとユーザはどこにも定義されておらず、どちらも私のデータソースではありません(どちらもdoc/examplesにありません)。私が理解する限り、デフォルトのdataSource ExampleDSを使用しているため、warファイルではできません。だから私は今それを.jarとしてデプロイしようとしているが、分数(jsfなど)の自動検出に失敗すると思うので、データソースを定義するだけの重い設定が必要なようだ。 – Ced